@commercetools-frontend/mc-scripts 21.7.0 → 21.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -42
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +1 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
- package/{build/config/application-runtime.js → application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js} +2 -2
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
- package/application-runtime/package.json +4 -0
- package/bin/cli.js +1 -1
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +1 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +345 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +7 -1
- package/config/create-webpack-config-for-production.js +7 -1
- package/config/vendors-to-transpile.js +5 -1
- package/dist/build-5357ad26.cjs.prod.js +224 -0
- package/dist/build-9b6d7eee.cjs.dev.js +224 -0
- package/dist/build-c483e87f.esm.js +209 -0
- package/dist/build-vite-3b82522e.cjs.dev.js +151 -0
- package/dist/build-vite-93abdc95.esm.js +139 -0
- package/dist/build-vite-b7cd993a.cjs.prod.js +151 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +1 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +22 -0
- package/dist/compile-html-4361a0b3.esm.js +77 -0
- package/dist/compile-html-d6331c35.cjs.prod.js +87 -0
- package/dist/compile-html-d9e731aa.cjs.dev.js +87 -0
- package/dist/config-sync-6b31d972.esm.js +840 -0
- package/dist/config-sync-a478bc0f.cjs.dev.js +864 -0
- package/dist/config-sync-f07734e4.cjs.prod.js +859 -0
- package/{build/config/create-postcss-config.js → dist/create-postcss-config-04243dea.esm.js} +27 -25
- package/dist/create-postcss-config-760e2dc5.cjs.dev.js +90 -0
- package/dist/create-postcss-config-ddc3abee.cjs.prod.js +90 -0
- package/dist/create-webpack-config-for-development-76fdab59.cjs.prod.js +419 -0
- package/{build/config/create-webpack-config-for-development.js → dist/create-webpack-config-for-development-d93ae4b2.esm.js} +94 -57
- package/dist/create-webpack-config-for-development-dfd1c174.cjs.dev.js +419 -0
- package/{build/config/create-webpack-config-for-production.js → dist/create-webpack-config-for-production-9290479a.esm.js} +120 -54
- package/dist/create-webpack-config-for-production-bc8c1f37.cjs.dev.js +469 -0
- package/dist/create-webpack-config-for-production-d652ad1a.cjs.prod.js +469 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/commands/build-vite.d.ts +2 -0
- package/dist/declarations/src/commands/build.d.ts +2 -0
- package/dist/declarations/src/commands/compile-html.d.ts +3 -0
- package/dist/declarations/src/commands/config-sync.d.ts +3 -0
- package/dist/declarations/src/commands/login.d.ts +2 -0
- package/dist/declarations/src/commands/serve.d.ts +2 -0
- package/dist/declarations/src/commands/start-vite.d.ts +2 -0
- package/dist/declarations/src/commands/start.d.ts +2 -0
- package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
- package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
- package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
- package/dist/declarations/src/config/has-jsx-runtime.d.ts +2 -0
- package/dist/declarations/src/config/moment-locales.d.ts +2 -0
- package/dist/declarations/src/config/paths.d.ts +12 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/generated/core.d.ts +710 -0
- package/dist/declarations/src/generated/settings.d.ts +2485 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/postcss.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +82 -0
- package/dist/declarations/src/utils/auth.d.ts +6 -0
- package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
- package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
- package/dist/declarations/src/utils/graphql-requests.d.ts +80 -0
- package/dist/declarations/src/utils/user-agent.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-custom-application.d.ts +4 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-dynamic-base-assets-globals.d.ts +3 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-svgr.d.ts +3 -0
- package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
- package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/has-jsx-runtime-0b03b72e.cjs.prod.js +17 -0
- package/dist/has-jsx-runtime-3d4bb633.cjs.dev.js +17 -0
- package/{build/config/has-jsx-runtime.js → dist/has-jsx-runtime-8314226e.esm.js} +1 -3
- package/dist/login-7b7ae27e.esm.js +155 -0
- package/dist/login-b13f26e7.cjs.dev.js +165 -0
- package/dist/login-c11fb977.cjs.prod.js +165 -0
- package/dist/package-4b4fcf02.cjs.prod.js +139 -0
- package/dist/package-4c3e3fb7.cjs.dev.js +139 -0
- package/dist/package-8e6305bd.esm.js +137 -0
- package/dist/paths-16823f56.cjs.dev.js +55 -0
- package/dist/paths-76b66e74.cjs.prod.js +55 -0
- package/dist/paths-ed23d5a1.esm.js +46 -0
- package/dist/serve-12de323b.cjs.dev.js +70 -0
- package/dist/serve-784f4fcd.cjs.prod.js +70 -0
- package/dist/serve-d6b437b1.esm.js +62 -0
- package/dist/start-1b7dad90.cjs.prod.js +209 -0
- package/dist/start-45ca01f2.cjs.dev.js +209 -0
- package/dist/start-600d06a3.esm.js +194 -0
- package/dist/start-vite-22de08dc.cjs.dev.js +151 -0
- package/dist/start-vite-dc046cba.esm.js +138 -0
- package/dist/start-vite-fe13330b.cjs.prod.js +151 -0
- package/dist/user-agent-5f8ec93d.cjs.prod.js +106 -0
- package/dist/user-agent-ca628320.esm.js +94 -0
- package/dist/user-agent-ee57c98a.cjs.dev.js +106 -0
- package/dist/vendors-to-transpile-367e0ba8.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-68e03526.esm.js +3 -0
- package/dist/vendors-to-transpile-b51af5d3.cjs.dev.js +5 -0
- package/dist/vite-plugin-svgr-4205f2b5.cjs.dev.js +110 -0
- package/dist/vite-plugin-svgr-eb8524fa.esm.js +85 -0
- package/dist/vite-plugin-svgr-f3bbedbe.cjs.prod.js +110 -0
- package/package.json +56 -50
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +1 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +6 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +1 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +42 -0
- package/webpack/package.json +4 -0
- package/build/bin/cli.js +0 -264
- package/build/commands/build-vite.js +0 -91
- package/build/commands/build.js +0 -140
- package/build/commands/compile-html.js +0 -53
- package/build/commands/config-sync.js +0 -176
- package/build/commands/login.js +0 -60
- package/build/commands/serve.js +0 -37
- package/build/commands/start-vite.js +0 -138
- package/build/commands/start.js +0 -108
- package/build/config/paths.js +0 -38
- package/build/config/vendors-to-transpile.js +0 -3
- package/build/config/webpack-dev-server.config.js +0 -69
- package/build/index.js +0 -16
- package/build/utils/auth.js +0 -34
- package/build/utils/auth.spec.js +0 -61
- package/build/utils/create-custom-application.settings.graphql +0 -8
- package/build/utils/credentials-storage.js +0 -72
- package/build/utils/credentials-storage.spec.js +0 -69
- package/build/utils/fetch-custom-application.settings.graphql +0 -36
- package/build/utils/fetch-user-organizations.core.graphql +0 -9
- package/build/utils/get-config-diff.js +0 -308
- package/build/utils/get-config-diff.spec.js +0 -285
- package/build/utils/graphql-requests.js +0 -105
- package/build/utils/graphql-requests.spec.js +0 -159
- package/build/utils/require-graphql.js +0 -15
- package/build/utils/update-custom-application.settings.graphql +0 -13
- package/build/utils/user-agent.js +0 -15
- package/build/webpack-plugins/final-stats-writer-plugin.js +0 -50
- package/build/webpack-plugins/local-html-webpack-plugin.js +0 -38
|
@@ -1,33 +1,101 @@
|
|
|
1
|
-
|
|
1
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
2
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
3
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
4
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
5
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
6
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
7
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
8
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
9
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
10
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
11
|
+
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
12
|
+
import _endsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/ends-with';
|
|
13
|
+
import _Number$isInteger from '@babel/runtime-corejs3/core-js-stable/number/is-integer';
|
|
14
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
15
|
+
import webpack from 'webpack';
|
|
16
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
17
|
+
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
18
|
+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
19
|
+
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
20
|
+
import MomentLocalesPlugin from 'moment-locales-webpack-plugin';
|
|
21
|
+
import TerserPlugin from 'terser-webpack-plugin';
|
|
22
|
+
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
23
|
+
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
24
|
+
import _bindInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/bind';
|
|
25
|
+
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
26
|
+
import _Object$assign from '@babel/runtime-corejs3/core-js-stable/object/assign';
|
|
27
|
+
import fs from 'fs';
|
|
28
|
+
import path from 'path';
|
|
29
|
+
import { p as paths } from './paths-ed23d5a1.esm.js';
|
|
30
|
+
import { v as vendorsToTranspile } from './vendors-to-transpile-68e03526.esm.js';
|
|
31
|
+
import { c as createPostcssConfig } from './create-postcss-config-04243dea.esm.js';
|
|
32
|
+
import { h as hasJsxRuntime } from './has-jsx-runtime-8314226e.esm.js';
|
|
2
33
|
|
|
3
|
-
|
|
4
|
-
|
|
34
|
+
var FinalStatsWriterPlugin = /*#__PURE__*/function () {
|
|
35
|
+
// Expected options:
|
|
36
|
+
// - `outputPath`
|
|
37
|
+
// - `includeFields`
|
|
38
|
+
function FinalStatsWriterPlugin(config) {
|
|
39
|
+
_classCallCheck(this, FinalStatsWriterPlugin);
|
|
5
40
|
|
|
6
|
-
|
|
41
|
+
this.config = void 0;
|
|
42
|
+
if (!config) throw new Error('Missing config options');
|
|
43
|
+
this.config = config;
|
|
44
|
+
}
|
|
7
45
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
46
|
+
_createClass(FinalStatsWriterPlugin, [{
|
|
47
|
+
key: "apply",
|
|
48
|
+
value: function apply(compiler) {
|
|
49
|
+
// This is the only hook that return the `stats` plugin
|
|
50
|
+
// with the `time` info. It also contains all the stats that
|
|
51
|
+
// we would get from the original `emit` hook.
|
|
52
|
+
// https://webpack.js.org/api/compiler-hooks/#done
|
|
53
|
+
// https://webpack.js.org/api/plugins/#plugin-types
|
|
54
|
+
if (compiler.hooks) {
|
|
55
|
+
var _context;
|
|
11
56
|
|
|
12
|
-
|
|
57
|
+
compiler.hooks.done.tap('custom-stats-writer-plugin', _bindInstanceProperty(_context = this.writeStats).call(_context, this));
|
|
58
|
+
} else {
|
|
59
|
+
var _context2;
|
|
13
60
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
compiler.plugin('done', _bindInstanceProperty(_context2 = this.writeStats).call(_context2, this));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "writeStats",
|
|
67
|
+
value: function writeStats(stats) {
|
|
68
|
+
var finalStats = stats.toJson(); // Filter only included fields
|
|
17
69
|
|
|
18
|
-
|
|
70
|
+
if (this.config.includeFields) {
|
|
71
|
+
var _context3;
|
|
19
72
|
|
|
20
|
-
|
|
73
|
+
finalStats = _reduceInstanceProperty(_context3 = this.config.includeFields).call(_context3, function (aggregatedStats, key) {
|
|
74
|
+
return (// eslint-disable-next-line
|
|
75
|
+
_Object$assign({}, aggregatedStats, _defineProperty({}, key, finalStats[key]))
|
|
76
|
+
);
|
|
77
|
+
}, {});
|
|
78
|
+
}
|
|
21
79
|
|
|
22
|
-
|
|
80
|
+
try {
|
|
81
|
+
fs.accessSync(this.config.outputPath, fs.constants.F_OK);
|
|
82
|
+
fs.writeFileSync(path.join(this.config.outputPath, 'stats.json'), _JSON$stringify(finalStats, null, 2));
|
|
83
|
+
} catch (error) {
|
|
84
|
+
// eslint-disable-next-line no-console
|
|
85
|
+
console.warn("[FinalStatsWriterPlugin] The dist folder could not be found at ".concat(this.config.outputPath, ". Check the console for errors during the webpack compilation."));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}]);
|
|
23
89
|
|
|
24
|
-
|
|
90
|
+
return FinalStatsWriterPlugin;
|
|
91
|
+
}();
|
|
25
92
|
|
|
26
|
-
|
|
93
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
94
|
|
|
28
|
-
|
|
95
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context7, _context8; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context7 = ownKeys(Object(source), !0)).call(_context7, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context8 = ownKeys(Object(source))).call(_context8, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
96
|
|
|
30
|
-
|
|
97
|
+
var momentLocalesToKeep = ["de", "de-at", "de-ch", "en-au", "en-ca", "en-gb", "en-ie", "en-in", "en-nz", "en-sg", "es", "es-do", "es-mx", "fr", "ja", "zh-cn"];
|
|
98
|
+
var defaultToggleFlags = {
|
|
31
99
|
// Allow to disable CSS extraction in case it's not necessary (e.g. for Storybook)
|
|
32
100
|
enableExtractCss: true,
|
|
33
101
|
// Allow to disable index.html generation in case it's not necessary (e.g. for Storybook)
|
|
@@ -44,7 +112,7 @@ const defaultToggleFlags = {
|
|
|
44
112
|
// `plugin-transform-runtime`.
|
|
45
113
|
disableCoreJs: false
|
|
46
114
|
};
|
|
47
|
-
|
|
115
|
+
var defaultOptions = {
|
|
48
116
|
entryPoint: paths.entryPoint,
|
|
49
117
|
sourceFolders: paths.sourceFolders,
|
|
50
118
|
postcssOptions: {},
|
|
@@ -55,21 +123,17 @@ const defaultOptions = {
|
|
|
55
123
|
* for a MC Application in `production` mode.
|
|
56
124
|
* The function requires the file path to the related application
|
|
57
125
|
* "entry point".
|
|
58
|
-
*
|
|
59
|
-
* @param {Object} options - Options to configure the Webpack config
|
|
60
|
-
* @param {string} options.entryPoint - The absolute path to the application entry point file.
|
|
61
|
-
* @param {string[]} options.sourceFolders[] - A list of folders where Webpack should look for source files.
|
|
62
|
-
* @param {Object} options.postcssOptions - Options related to Postcss plugins. See `createPostcssConfig` function.
|
|
63
|
-
* @param {Object} options.toggleFlags - Options to enable/disable certain functionalities of the Webpack config.
|
|
64
126
|
*/
|
|
65
127
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
128
|
+
function createWebpackConfigForProduction() {
|
|
129
|
+
var _context, _context2, _context3, _context4, _context5, _context6;
|
|
130
|
+
|
|
131
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
132
|
+
|
|
133
|
+
var mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, defaultOptions), options), {}, {
|
|
134
|
+
toggleFlags: _objectSpread(_objectSpread({}, defaultToggleFlags), options.toggleFlags)
|
|
135
|
+
});
|
|
136
|
+
|
|
73
137
|
return {
|
|
74
138
|
// Don't attempt to continue if there are any errors.
|
|
75
139
|
bail: true,
|
|
@@ -82,15 +146,15 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
82
146
|
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
|
83
147
|
// https://medium.com/webpack/webpack-4-mode-and-optimization-5423a6bc597a
|
|
84
148
|
optimization: {
|
|
85
|
-
minimizer: [new TerserPlugin({
|
|
149
|
+
minimizer: _filterInstanceProperty(_context = [new TerserPlugin({
|
|
86
150
|
terserOptions: {
|
|
87
151
|
parse: {
|
|
88
152
|
// we want terser to parse ecma 8 code. However, we don't want it
|
|
89
|
-
// to apply any
|
|
153
|
+
// to apply any minification steps that turns valid ecma 5 code
|
|
90
154
|
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
91
155
|
// sections only apply transformations that are ecma 5 safe
|
|
92
156
|
// https://github.com/facebook/create-react-app/pull/4234
|
|
93
|
-
ecma:
|
|
157
|
+
ecma: 2018
|
|
94
158
|
},
|
|
95
159
|
compress: {
|
|
96
160
|
ecma: 5,
|
|
@@ -123,7 +187,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
123
187
|
// Use multi-process parallel running to improve the build speed
|
|
124
188
|
// Default number of concurrent runs: os.cpus().length - 1
|
|
125
189
|
parallel: mergedOptions.toggleFlags.parallelism
|
|
126
|
-
}), mergedOptions.toggleFlags.enableExtractCss && new CssMinimizerPlugin()].
|
|
190
|
+
}), mergedOptions.toggleFlags.enableExtractCss && new CssMinimizerPlugin()]).call(_context, Boolean),
|
|
127
191
|
// Keep the runtime chunk separated to enable long term caching
|
|
128
192
|
runtimeChunk: {
|
|
129
193
|
name: 'runtime'
|
|
@@ -138,7 +202,9 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
138
202
|
// https://github.com/facebook/create-react-app/issues/290
|
|
139
203
|
// `web` extension prefixes have been added for better support
|
|
140
204
|
// for React Native Web.
|
|
141
|
-
extensions: ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx'].
|
|
205
|
+
extensions: _mapInstanceProperty(_context2 = ['js', 'mjs', 'cjs', 'ts', 'tsx', 'json', 'jsx']).call(_context2, function (ext) {
|
|
206
|
+
return ".".concat(ext);
|
|
207
|
+
}),
|
|
142
208
|
// NOTE: this is meant to be a temporary list of fallback/polyfills for certain
|
|
143
209
|
// nodejs modules. With Webpack <5 these polyfills were included by default in Webpack,
|
|
144
210
|
// however now it's not the case anymore.
|
|
@@ -149,7 +215,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
149
215
|
},
|
|
150
216
|
// In production, we only want to load the polyfills and the app code.
|
|
151
217
|
entry: {
|
|
152
|
-
app: [require.resolve('
|
|
218
|
+
app: _filterInstanceProperty(_context3 = [require.resolve('@commercetools-frontend/mc-scripts/application-runtime'), !mergedOptions.toggleFlags.disableCoreJs && require.resolve('core-js/stable'), mergedOptions.entryPoint]).call(_context3, Boolean)
|
|
153
219
|
},
|
|
154
220
|
output: {
|
|
155
221
|
// Generated JS file names (with nested folders).
|
|
@@ -162,7 +228,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
162
228
|
// Will be injected on runtime. See `packages/application-shell/src/public-path.js`
|
|
163
229
|
publicPath: ''
|
|
164
230
|
},
|
|
165
|
-
plugins: [// Allows to "assign" custom options to the `webpack` object.
|
|
231
|
+
plugins: _filterInstanceProperty(_context4 = [// Allows to "assign" custom options to the `webpack` object.
|
|
166
232
|
// At the moment, this is used to share some props with `postcss.config`.
|
|
167
233
|
new webpack.LoaderOptionsPlugin({
|
|
168
234
|
options: {
|
|
@@ -174,12 +240,11 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
174
240
|
new webpack.DefinePlugin({
|
|
175
241
|
__DEV__: 'false',
|
|
176
242
|
'process.env': {
|
|
177
|
-
NODE_ENV:
|
|
243
|
+
NODE_ENV: _JSON$stringify('production')
|
|
178
244
|
}
|
|
179
|
-
}), //
|
|
180
|
-
// (`en` is built into Moment and can't be removed)
|
|
245
|
+
}), // Only keep locales that are available in the Merchant Center.
|
|
181
246
|
new MomentLocalesPlugin({
|
|
182
|
-
localesToKeep:
|
|
247
|
+
localesToKeep: momentLocalesToKeep
|
|
183
248
|
}), // Generate a `stats.json` file containing information and paths to
|
|
184
249
|
// the assets that webpack created.
|
|
185
250
|
// This is necessary to programmatically refer to the correct bundle path
|
|
@@ -197,11 +262,11 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
197
262
|
chunkFilename: '[id].[name].[chunkhash].css'
|
|
198
263
|
}), process.env.ANALYZE_BUNDLE === 'true' && new BundleAnalyzerPlugin({
|
|
199
264
|
defaultSizes: 'gzip'
|
|
200
|
-
})].
|
|
265
|
+
})]).call(_context4, Boolean),
|
|
201
266
|
module: {
|
|
202
267
|
// Makes missing exports an error instead of warning.
|
|
203
268
|
strictExportPresence: true,
|
|
204
|
-
rules: [// For svg icons, we want to get them transformed into React components
|
|
269
|
+
rules: _filterInstanceProperty(_context5 = [// For svg icons, we want to get them transformed into React components
|
|
205
270
|
// when we import them.
|
|
206
271
|
{
|
|
207
272
|
test: /\.react\.svg$/,
|
|
@@ -242,7 +307,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
242
307
|
test: function testForNormalSvgFiles(fileName) {
|
|
243
308
|
return (// Use this only for plain SVG.
|
|
244
309
|
// For SVG as React components, see loader above.
|
|
245
|
-
fileName.
|
|
310
|
+
_endsWithInstanceProperty(fileName).call(fileName, '.svg') && !_endsWithInstanceProperty(fileName).call(fileName, '.react.svg')
|
|
246
311
|
);
|
|
247
312
|
},
|
|
248
313
|
use: [{
|
|
@@ -281,7 +346,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
281
346
|
test: function testForNormalCssFiles(fileName) {
|
|
282
347
|
return (// Use this only for plain CSS.
|
|
283
348
|
// For css-modules, see loader above.
|
|
284
|
-
fileName.
|
|
349
|
+
_endsWithInstanceProperty(fileName).call(fileName, '.css') && !(_endsWithInstanceProperty(fileName).call(fileName, '.mod.css') || _endsWithInstanceProperty(fileName).call(fileName, '.module.css'))
|
|
285
350
|
);
|
|
286
351
|
},
|
|
287
352
|
// "postcss" loader applies autoprefixer to our CSS.
|
|
@@ -334,10 +399,9 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
334
399
|
// improves compile time on larger projects
|
|
335
400
|
{
|
|
336
401
|
loader: require.resolve('thread-loader'),
|
|
337
|
-
options: {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
402
|
+
options: _objectSpread({}, _Number$isInteger(mergedOptions.toggleFlags.parallelism) ? {
|
|
403
|
+
workers: mergedOptions.toggleFlags.parallelism
|
|
404
|
+
} : {})
|
|
341
405
|
}, {
|
|
342
406
|
loader: require.resolve('babel-loader'),
|
|
343
407
|
options: {
|
|
@@ -354,7 +418,7 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
354
418
|
highlightCode: true
|
|
355
419
|
}
|
|
356
420
|
}],
|
|
357
|
-
include: mergedOptions.sourceFolders.
|
|
421
|
+
include: _concatInstanceProperty(_context6 = mergedOptions.sourceFolders).call(_context6, vendorsToTranspile),
|
|
358
422
|
// Disable require.ensure as it's not a standard language feature.
|
|
359
423
|
parser: {
|
|
360
424
|
requireEnsure: false
|
|
@@ -365,10 +429,12 @@ module.exports = function createWebpackConfigForProduction(options = {}) {
|
|
|
365
429
|
include: mergedOptions.sourceFolders,
|
|
366
430
|
exclude: /node_modules/,
|
|
367
431
|
use: [require.resolve('graphql-tag/loader')]
|
|
368
|
-
}].
|
|
432
|
+
}]).call(_context5, Boolean)
|
|
369
433
|
},
|
|
370
434
|
// Turn off performance processing because we utilize
|
|
371
435
|
// our own hints via the FileSizeReporter
|
|
372
436
|
performance: false
|
|
373
437
|
};
|
|
374
|
-
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export { createWebpackConfigForProduction as c };
|