<commit_before>/* global process, require, module, __dirname */

const path = require( 'path' );

const externals = {
	// Make localized data importable.
	'amp-validation-i18n': 'ampValidationI18n',
	jquery: 'jQuery',
	lodash: 'lodash',
	react: 'React',
	'react-dom': 'ReactDOM',
};

// Define WordPress dependencies
const wpDependencies = [
	'blocks',
	'components',
	'compose',
	'data',
	'editor',
	'edit-post',
	'element',
	'hooks',
	'i18n',
	'api-fetch',
	'blocks',
	'components',
	'compose',
	'date',
	'editor',
	'element',
	'hooks',
	'i18n',
	'utils',
	'data',
	'viewport',
	'core-data',
	'plugins',
	'edit-post',
	'keycodes',
	'wordcount',
];

/**
 * Given a string, returns a new string with dash separators converted to
 * camel-case equivalent. This is not as aggressive as `_.camelCase` in
 * converting to uppercase, where Lodash will convert letters following
 * numbers.
 *
 * @param {string} string Input dash-delimited string.
 *
 * @return {string} Camel-cased string.
 */
function camelCaseDash( string ) {
	return string.replace(
		/-([a-z])/,
		( match, letter ) => letter.toUpperCase()
	);
}

wpDependencies.forEach( ( name ) => {
	externals[ `@wordpress/${ name }` ] = {
		this: [ 'wp', camelCaseDash( name ) ],
	};
} );

const isProduction = process.env.NODE_ENV === 'production';

module.exports = {
	mode: isProduction ? 'production' : 'development',
	entry: {
		'./assets/js/amp-blocks-compiled': './assets/src/blocks/index.js',
		'./assets/js/amp-block-editor-toggle-compiled': './assets/src/amp-block-editor-toggle.js',
		'./assets/js/amp-validation-detail-toggle-compiled': './assets/src/amp-validation-detail-toggle.js',
		'./assets/js/amp-validation-single-error-url-details-compiled': './assets/src/amp-validation-single-error-url-details.js',
		'./assets/js/amp-story-editor-blocks-compiled': './assets/src/amp-story-editor-blocks.js',
		'./assets/js/amp-story-blocks-compiled': './assets/src/blocks/stories.js',
	},
	output: {
		path: path.resolve( __dirname ),
		filename: '[name].js',
		library: 'AMP',
		libraryTarget: 'this',
	},
	externals,
	devtool: isProduction ? undefined : 'cheap-eval-source-map',
	module: {
		rules: [
			{
				test: /\.js$/,
				exclude: /node_modules/,
				use: {
					loader: 'babel-loader',
				},
			},
		],<commit_msg>Enqueue the Latest Stories block JS even outside of Native AMP<commit_after>/* global process, require, module, __dirname */

const path = require( 'path' );

const externals = {
	// Make localized data importable.
	'amp-validation-i18n': 'ampValidationI18n',
	jquery: 'jQuery',
	lodash: 'lodash',
	react: 'React',
	'react-dom': 'ReactDOM',
};

// Define WordPress dependencies
const wpDependencies = [
	'blocks',
	'components',
	'compose',
	'data',
	'editor',
	'edit-post',
	'element',
	'hooks',
	'i18n',
	'api-fetch',
	'blocks',
	'components',
	'compose',
	'date',
	'editor',
	'element',
	'hooks',
	'i18n',
	'utils',
	'data',
	'viewport',
	'core-data',
	'plugins',
	'edit-post',
	'keycodes',
	'wordcount',
];

/**
 * Given a string, returns a new string with dash separators converted to
 * camel-case equivalent. This is not as aggressive as `_.camelCase` in
 * converting to uppercase, where Lodash will convert letters following
 * numbers.
 *
 * @param {string} string Input dash-delimited string.
 *
 * @return {string} Camel-cased string.
 */
function camelCaseDash( string ) {
	return string.replace(
		/-([a-z])/,
		( match, letter ) => letter.toUpperCase()
	);
}

wpDependencies.forEach( ( name ) => {
	externals[ `@wordpress/${ name }` ] = {
		this: [ 'wp', camelCaseDash( name ) ],
	};
} );

const isProduction = process.env.NODE_ENV === 'production';

module.exports = {
	mode: isProduction ? 'production' : 'development',
	entry: {
		'./assets/js/amp-blocks-compiled': './assets/src/blocks/index.js',
		'./assets/js/amp-block-editor-toggle-compiled': './assets/src/amp-block-editor-toggle.js',
		'./assets/js/amp-validation-detail-toggle-compiled': './assets/src/amp-validation-detail-toggle.js',
		'./assets/js/amp-validation-single-error-url-details-compiled': './assets/src/amp-validation-single-error-url-details.js',
		'./assets/js/amp-story-editor-blocks-compiled': './assets/src/amp-story-editor-blocks.js',
		'./assets/js/amp-story-blocks-compiled': './assets/src/blocks/stories.js',
		'./assets/js/amp-agnostic-blocks-compiled': './assets/src/blocks/amp-agnostic.js',
	},
	output: {
		path: path.resolve( __dirname ),
		filename: '[name].js',
		library: 'AMP',
		libraryTarget: 'this',
	},
	externals,
	devtool: isProduction ? undefined : 'cheap-eval-source-map',
	module: {
		rules: [
			{
				test: /\.js$/,
				exclude: /node_modules/,
				use: {
					loader: 'babel-loader',
				},
			},
		],
{'fraction_non_alphanumeric': 0.1920951976200595, 'fraction_numerical': 0.003399915002124947, 'mean_word_length': 3.749747729566095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '186221', 'n_tokens_mistral': 1795, 'n_tokens_neox': 1673, 'n_words': 338}