@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
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
4
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
5
|
+
var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var fs = require('fs-extra');
|
|
8
|
+
var webpack = require('webpack');
|
|
9
|
+
var chalk = require('chalk');
|
|
10
|
+
var checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
|
11
|
+
var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
12
|
+
var FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
13
|
+
var printBuildError = require('react-dev-utils/printBuildError');
|
|
14
|
+
var assets = require('@commercetools-frontend/assets');
|
|
15
|
+
var paths = require('./paths-16823f56.cjs.dev.js');
|
|
16
|
+
var createWebpackConfigForProduction = require('./create-webpack-config-for-production-bc8c1f37.cjs.dev.js');
|
|
17
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
18
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
19
|
+
require('fs');
|
|
20
|
+
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
21
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
22
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
23
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
24
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
25
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
26
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
27
|
+
require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
28
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
29
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
30
|
+
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
31
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
|
|
32
|
+
require('@babel/runtime-corejs3/core-js-stable/number/is-integer');
|
|
33
|
+
require('html-webpack-plugin');
|
|
34
|
+
require('webpack-bundle-analyzer');
|
|
35
|
+
require('css-minimizer-webpack-plugin');
|
|
36
|
+
require('mini-css-extract-plugin');
|
|
37
|
+
require('moment-locales-webpack-plugin');
|
|
38
|
+
require('terser-webpack-plugin');
|
|
39
|
+
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
40
|
+
require('@babel/runtime-corejs3/helpers/createClass');
|
|
41
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
42
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
43
|
+
require('@babel/runtime-corejs3/core-js-stable/object/assign');
|
|
44
|
+
require('./vendors-to-transpile-b51af5d3.cjs.dev.js');
|
|
45
|
+
require('./create-postcss-config-760e2dc5.cjs.dev.js');
|
|
46
|
+
require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
47
|
+
require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
48
|
+
require('./package-4c3e3fb7.cjs.dev.js');
|
|
49
|
+
require('./has-jsx-runtime-3d4bb633.cjs.dev.js');
|
|
50
|
+
|
|
51
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
52
|
+
|
|
53
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
54
|
+
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
55
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
56
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
57
|
+
var webpack__default = /*#__PURE__*/_interopDefault(webpack);
|
|
58
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
59
|
+
var checkRequiredFiles__default = /*#__PURE__*/_interopDefault(checkRequiredFiles);
|
|
60
|
+
var formatWebpackMessages__default = /*#__PURE__*/_interopDefault(formatWebpackMessages);
|
|
61
|
+
var FileSizeReporter__default = /*#__PURE__*/_interopDefault(FileSizeReporter);
|
|
62
|
+
var printBuildError__default = /*#__PURE__*/_interopDefault(printBuildError);
|
|
63
|
+
|
|
64
|
+
var measureFileSizesBeforeBuild = FileSizeReporter__default["default"].measureFileSizesBeforeBuild;
|
|
65
|
+
var printFileSizesAfterBuild = FileSizeReporter__default["default"].printFileSizesAfterBuild; // These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
66
|
+
|
|
67
|
+
var WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
68
|
+
var WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
69
|
+
|
|
70
|
+
function run() {
|
|
71
|
+
return _run.apply(this, arguments);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function _run() {
|
|
75
|
+
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
|
|
76
|
+
var hasWebpackConfig, previousFileSizes, result, build, _build, copyDefaultFiles;
|
|
77
|
+
|
|
78
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
79
|
+
while (1) {
|
|
80
|
+
switch (_context2.prev = _context2.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
copyDefaultFiles = function _copyDefaultFiles() {
|
|
83
|
+
fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
|
|
84
|
+
dereference: true
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
_build = function _build3() {
|
|
89
|
+
_build = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
90
|
+
var config, compiler;
|
|
91
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
92
|
+
while (1) {
|
|
93
|
+
switch (_context.prev = _context.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
console.log('Creating an optimized production build...');
|
|
96
|
+
config = hasWebpackConfig ? require(paths.paths.appWebpackConfig) : createWebpackConfigForProduction.createWebpackConfigForProduction();
|
|
97
|
+
compiler = webpack__default["default"](config);
|
|
98
|
+
return _context.abrupt("return", new _Promise__default["default"](function (resolve, reject) {
|
|
99
|
+
compiler.run(function (err, stats) {
|
|
100
|
+
var messages;
|
|
101
|
+
|
|
102
|
+
if (err) {
|
|
103
|
+
if (!err.message) {
|
|
104
|
+
return reject(err);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
var errMessage = err.message; // Add additional information for postcss errors
|
|
108
|
+
|
|
109
|
+
// Add additional information for postcss errors
|
|
110
|
+
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
111
|
+
errMessage += '\nCompileError: Begins at CSS selector ' + // @ts-ignore
|
|
112
|
+
err['postcssNode'].selector;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
messages = formatWebpackMessages__default["default"]({
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
errors: [errMessage],
|
|
118
|
+
warnings: []
|
|
119
|
+
});
|
|
120
|
+
} else {
|
|
121
|
+
messages = formatWebpackMessages__default["default"](stats === null || stats === void 0 ? void 0 : stats.toJson({
|
|
122
|
+
all: false,
|
|
123
|
+
warnings: true,
|
|
124
|
+
errors: true
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (messages.errors.length) {
|
|
129
|
+
// Only keep the first error. Others are often indicative
|
|
130
|
+
// of the same problem, but confuse the reader with noise.
|
|
131
|
+
if (messages.errors.length > 1) {
|
|
132
|
+
messages.errors.length = 1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return reject(new Error(messages.errors.join('\n\n')));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
|
|
139
|
+
console.log(chalk__default["default"].yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
|
|
140
|
+
return reject(new Error(messages.warnings.join('\n\n')));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return resolve({
|
|
144
|
+
stats: stats,
|
|
145
|
+
warnings: messages.warnings
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}));
|
|
149
|
+
|
|
150
|
+
case 4:
|
|
151
|
+
case "end":
|
|
152
|
+
return _context.stop();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, _callee);
|
|
156
|
+
}));
|
|
157
|
+
return _build.apply(this, arguments);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
build = function _build2() {
|
|
161
|
+
return _build.apply(this, arguments);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
hasWebpackConfig = fs__default["default"].existsSync(paths.paths.appWebpackConfig); // Warn and crash if required files are missing
|
|
165
|
+
|
|
166
|
+
if (!checkRequiredFiles__default["default"]([])) {
|
|
167
|
+
process.exit(1);
|
|
168
|
+
} // First, read the current file sizes in build directory.
|
|
169
|
+
// This lets us display how much they changed later.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
_context2.next = 7;
|
|
173
|
+
return measureFileSizesBeforeBuild(paths.paths.appBuild);
|
|
174
|
+
|
|
175
|
+
case 7:
|
|
176
|
+
previousFileSizes = _context2.sent;
|
|
177
|
+
// Remove all content but keep the directory so that
|
|
178
|
+
// if you're in it, you don't end up in Trash
|
|
179
|
+
fs__default["default"].emptyDirSync(paths.paths.appBuild); // Copy default files
|
|
180
|
+
|
|
181
|
+
copyDefaultFiles();
|
|
182
|
+
_context2.prev = 10;
|
|
183
|
+
_context2.next = 13;
|
|
184
|
+
return build();
|
|
185
|
+
|
|
186
|
+
case 13:
|
|
187
|
+
result = _context2.sent;
|
|
188
|
+
|
|
189
|
+
if (result.warnings.length) {
|
|
190
|
+
console.log(chalk__default["default"].yellow('Compiled with warnings.\n'));
|
|
191
|
+
console.log(result.warnings.join('\n\n'));
|
|
192
|
+
console.log("\nSearch for the ".concat(chalk__default["default"].underline(chalk__default["default"].yellow('keywords')), " to learn more about each warning."));
|
|
193
|
+
console.log("To ignore, add ".concat(chalk__default["default"].cyan('// eslint-disable-next-line'), " to the line before.\n"));
|
|
194
|
+
} else {
|
|
195
|
+
console.log(chalk__default["default"].green('Compiled successfully.\n'));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
console.log('File sizes after gzip:\n');
|
|
199
|
+
printFileSizesAfterBuild(result.stats, previousFileSizes, paths.paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
|
|
200
|
+
console.log();
|
|
201
|
+
_context2.next = 24;
|
|
202
|
+
break;
|
|
203
|
+
|
|
204
|
+
case 20:
|
|
205
|
+
_context2.prev = 20;
|
|
206
|
+
_context2.t0 = _context2["catch"](10);
|
|
207
|
+
|
|
208
|
+
if (_context2.t0 instanceof Error) {
|
|
209
|
+
printBuildError__default["default"](_context2.t0);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
throw new Error("Failed to compile");
|
|
213
|
+
|
|
214
|
+
case 24:
|
|
215
|
+
case "end":
|
|
216
|
+
return _context2.stop();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}, _callee2, null, [[10, 20]]);
|
|
220
|
+
}));
|
|
221
|
+
return _run.apply(this, arguments);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
exports["default"] = run;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
|
|
2
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
3
|
+
import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import webpack from 'webpack';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import checkRequiredFiles from 'react-dev-utils/checkRequiredFiles';
|
|
9
|
+
import formatWebpackMessages from 'react-dev-utils/formatWebpackMessages';
|
|
10
|
+
import FileSizeReporter from 'react-dev-utils/FileSizeReporter';
|
|
11
|
+
import printBuildError from 'react-dev-utils/printBuildError';
|
|
12
|
+
import { packageLocation } from '@commercetools-frontend/assets';
|
|
13
|
+
import { p as paths } from './paths-ed23d5a1.esm.js';
|
|
14
|
+
import { c as createWebpackConfigForProduction } from './create-webpack-config-for-production-9290479a.esm.js';
|
|
15
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
16
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
17
|
+
import 'fs';
|
|
18
|
+
import '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
19
|
+
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
20
|
+
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
21
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
22
|
+
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
23
|
+
import '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
24
|
+
import '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
25
|
+
import '@babel/runtime-corejs3/helpers/defineProperty';
|
|
26
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
27
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
28
|
+
import '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
29
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/ends-with';
|
|
30
|
+
import '@babel/runtime-corejs3/core-js-stable/number/is-integer';
|
|
31
|
+
import 'html-webpack-plugin';
|
|
32
|
+
import 'webpack-bundle-analyzer';
|
|
33
|
+
import 'css-minimizer-webpack-plugin';
|
|
34
|
+
import 'mini-css-extract-plugin';
|
|
35
|
+
import 'moment-locales-webpack-plugin';
|
|
36
|
+
import 'terser-webpack-plugin';
|
|
37
|
+
import '@babel/runtime-corejs3/helpers/classCallCheck';
|
|
38
|
+
import '@babel/runtime-corejs3/helpers/createClass';
|
|
39
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/bind';
|
|
40
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
41
|
+
import '@babel/runtime-corejs3/core-js-stable/object/assign';
|
|
42
|
+
import './vendors-to-transpile-68e03526.esm.js';
|
|
43
|
+
import './create-postcss-config-04243dea.esm.js';
|
|
44
|
+
import '@babel/runtime-corejs3/helpers/toConsumableArray';
|
|
45
|
+
import '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
46
|
+
import './package-8e6305bd.esm.js';
|
|
47
|
+
import './has-jsx-runtime-8314226e.esm.js';
|
|
48
|
+
|
|
49
|
+
var measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild;
|
|
50
|
+
var printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild; // These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
51
|
+
|
|
52
|
+
var WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
53
|
+
var WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
54
|
+
|
|
55
|
+
function run() {
|
|
56
|
+
return _run.apply(this, arguments);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function _run() {
|
|
60
|
+
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
61
|
+
var hasWebpackConfig, previousFileSizes, result, build, _build, copyDefaultFiles;
|
|
62
|
+
|
|
63
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
64
|
+
while (1) {
|
|
65
|
+
switch (_context2.prev = _context2.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
copyDefaultFiles = function _copyDefaultFiles() {
|
|
68
|
+
fs.copySync(path.join(packageLocation, 'html-page'), paths.appBuild, {
|
|
69
|
+
dereference: true
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
_build = function _build3() {
|
|
74
|
+
_build = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
75
|
+
var config, compiler;
|
|
76
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
77
|
+
while (1) {
|
|
78
|
+
switch (_context.prev = _context.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
console.log('Creating an optimized production build...');
|
|
81
|
+
config = hasWebpackConfig ? require(paths.appWebpackConfig) : createWebpackConfigForProduction();
|
|
82
|
+
compiler = webpack(config);
|
|
83
|
+
return _context.abrupt("return", new _Promise(function (resolve, reject) {
|
|
84
|
+
compiler.run(function (err, stats) {
|
|
85
|
+
var messages;
|
|
86
|
+
|
|
87
|
+
if (err) {
|
|
88
|
+
if (!err.message) {
|
|
89
|
+
return reject(err);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
var errMessage = err.message; // Add additional information for postcss errors
|
|
93
|
+
|
|
94
|
+
// Add additional information for postcss errors
|
|
95
|
+
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
96
|
+
errMessage += '\nCompileError: Begins at CSS selector ' + // @ts-ignore
|
|
97
|
+
err['postcssNode'].selector;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
messages = formatWebpackMessages({
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
errors: [errMessage],
|
|
103
|
+
warnings: []
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
messages = formatWebpackMessages(stats === null || stats === void 0 ? void 0 : stats.toJson({
|
|
107
|
+
all: false,
|
|
108
|
+
warnings: true,
|
|
109
|
+
errors: true
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (messages.errors.length) {
|
|
114
|
+
// Only keep the first error. Others are often indicative
|
|
115
|
+
// of the same problem, but confuse the reader with noise.
|
|
116
|
+
if (messages.errors.length > 1) {
|
|
117
|
+
messages.errors.length = 1;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return reject(new Error(messages.errors.join('\n\n')));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
|
|
124
|
+
console.log(chalk.yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
|
|
125
|
+
return reject(new Error(messages.warnings.join('\n\n')));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return resolve({
|
|
129
|
+
stats: stats,
|
|
130
|
+
warnings: messages.warnings
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}));
|
|
134
|
+
|
|
135
|
+
case 4:
|
|
136
|
+
case "end":
|
|
137
|
+
return _context.stop();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}, _callee);
|
|
141
|
+
}));
|
|
142
|
+
return _build.apply(this, arguments);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
build = function _build2() {
|
|
146
|
+
return _build.apply(this, arguments);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
hasWebpackConfig = fs.existsSync(paths.appWebpackConfig); // Warn and crash if required files are missing
|
|
150
|
+
|
|
151
|
+
if (!checkRequiredFiles([])) {
|
|
152
|
+
process.exit(1);
|
|
153
|
+
} // First, read the current file sizes in build directory.
|
|
154
|
+
// This lets us display how much they changed later.
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
_context2.next = 7;
|
|
158
|
+
return measureFileSizesBeforeBuild(paths.appBuild);
|
|
159
|
+
|
|
160
|
+
case 7:
|
|
161
|
+
previousFileSizes = _context2.sent;
|
|
162
|
+
// Remove all content but keep the directory so that
|
|
163
|
+
// if you're in it, you don't end up in Trash
|
|
164
|
+
fs.emptyDirSync(paths.appBuild); // Copy default files
|
|
165
|
+
|
|
166
|
+
copyDefaultFiles();
|
|
167
|
+
_context2.prev = 10;
|
|
168
|
+
_context2.next = 13;
|
|
169
|
+
return build();
|
|
170
|
+
|
|
171
|
+
case 13:
|
|
172
|
+
result = _context2.sent;
|
|
173
|
+
|
|
174
|
+
if (result.warnings.length) {
|
|
175
|
+
console.log(chalk.yellow('Compiled with warnings.\n'));
|
|
176
|
+
console.log(result.warnings.join('\n\n'));
|
|
177
|
+
console.log("\nSearch for the ".concat(chalk.underline(chalk.yellow('keywords')), " to learn more about each warning."));
|
|
178
|
+
console.log("To ignore, add ".concat(chalk.cyan('// eslint-disable-next-line'), " to the line before.\n"));
|
|
179
|
+
} else {
|
|
180
|
+
console.log(chalk.green('Compiled successfully.\n'));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
console.log('File sizes after gzip:\n');
|
|
184
|
+
printFileSizesAfterBuild(result.stats, previousFileSizes, paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
|
|
185
|
+
console.log();
|
|
186
|
+
_context2.next = 24;
|
|
187
|
+
break;
|
|
188
|
+
|
|
189
|
+
case 20:
|
|
190
|
+
_context2.prev = 20;
|
|
191
|
+
_context2.t0 = _context2["catch"](10);
|
|
192
|
+
|
|
193
|
+
if (_context2.t0 instanceof Error) {
|
|
194
|
+
printBuildError(_context2.t0);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
throw new Error("Failed to compile");
|
|
198
|
+
|
|
199
|
+
case 24:
|
|
200
|
+
case "end":
|
|
201
|
+
return _context2.stop();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}, _callee2, null, [[10, 20]]);
|
|
205
|
+
}));
|
|
206
|
+
return _run.apply(this, arguments);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export { run as default };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
4
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
5
|
+
var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
|
|
6
|
+
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
7
|
+
var fs = require('fs-extra');
|
|
8
|
+
var path = require('path');
|
|
9
|
+
var vite = require('vite');
|
|
10
|
+
var pluginGraphql = require('@rollup/plugin-graphql');
|
|
11
|
+
var pluginReact = require('@vitejs/plugin-react');
|
|
12
|
+
var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
|
|
13
|
+
var assets = require('@commercetools-frontend/assets');
|
|
14
|
+
var paths = require('./paths-16823f56.cjs.dev.js');
|
|
15
|
+
var vitePluginSvgr = require('./vite-plugin-svgr-4205f2b5.cjs.dev.js');
|
|
16
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
17
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
18
|
+
require('fs');
|
|
19
|
+
require('@rollup/pluginutils');
|
|
20
|
+
|
|
21
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
22
|
+
|
|
23
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
24
|
+
var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
25
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
26
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
27
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
28
|
+
var pluginGraphql__default = /*#__PURE__*/_interopDefault(pluginGraphql);
|
|
29
|
+
var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
|
|
30
|
+
|
|
31
|
+
// This script/function is injected into the `index.html` and used by Vite
|
|
32
|
+
// on runtime to build the assets URL (for example when using a separate CDN for the assets).
|
|
33
|
+
// Inspired by https://github.com/vitejs/vite/blob/main/playground/assets/vite.config-runtime-base.js
|
|
34
|
+
var dynamicBaseAssetsCode = "globalThis.__toCdnUrl = filePath => window.app.cdnUrl.replace(/\\/$/, '') + '/' + filePath;";
|
|
35
|
+
|
|
36
|
+
function vitePluginDynamicBaseAssetsGlobals() {
|
|
37
|
+
return {
|
|
38
|
+
name: 'dynamic-base-assets-globals',
|
|
39
|
+
transformIndexHtml: function transformIndexHtml(html, ctx) {
|
|
40
|
+
if (ctx.bundle) {
|
|
41
|
+
// Only inject during build
|
|
42
|
+
return [{
|
|
43
|
+
tag: 'script',
|
|
44
|
+
attrs: {
|
|
45
|
+
type: 'module'
|
|
46
|
+
},
|
|
47
|
+
children: dynamicBaseAssetsCode
|
|
48
|
+
}];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return html;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function run() {
|
|
57
|
+
return _run.apply(this, arguments);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _run() {
|
|
61
|
+
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
62
|
+
var DEFAULT_PORT, appEntryPoint, html;
|
|
63
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
64
|
+
while (1) {
|
|
65
|
+
switch (_context.prev = _context.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
DEFAULT_PORT = _parseInt__default["default"](String(process.env.HTTP_PORT), 10) || 3001; // Ensure the `/public` folder exists.
|
|
68
|
+
|
|
69
|
+
fs__default["default"].mkdirSync(paths.paths.appBuild, {
|
|
70
|
+
recursive: true
|
|
71
|
+
}); // Generate `index.html` (template).
|
|
72
|
+
|
|
73
|
+
appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
|
|
74
|
+
html = mcHtmlTemplate.generateTemplate({
|
|
75
|
+
// Define the module entry point (path relative from the `/public` folder).
|
|
76
|
+
// NOTE: that this is different from the development configuration.
|
|
77
|
+
scriptImports: ["<script type=\"module\" src=\"/".concat(appEntryPoint, "\"></script>")]
|
|
78
|
+
}); // Write `index.html` (template) into the `/public` folder.
|
|
79
|
+
|
|
80
|
+
fs__default["default"].writeFileSync(paths.paths.appIndexHtml, html, {
|
|
81
|
+
encoding: 'utf8'
|
|
82
|
+
});
|
|
83
|
+
_context.next = 7;
|
|
84
|
+
return vite.build({
|
|
85
|
+
root: paths.paths.appRoot,
|
|
86
|
+
base: './',
|
|
87
|
+
// <-- Important to allow configuring the runtime base path.
|
|
88
|
+
define: {
|
|
89
|
+
'process.env.DEBUG': _JSON$stringify__default["default"](false),
|
|
90
|
+
'process.env.NODE_ENV': _JSON$stringify__default["default"]('production')
|
|
91
|
+
},
|
|
92
|
+
build: {
|
|
93
|
+
outDir: 'public',
|
|
94
|
+
rollupOptions: {
|
|
95
|
+
// This is necessary to instruct Vite that the `index.html` (template)
|
|
96
|
+
// is located in the `/public` folder.
|
|
97
|
+
// NOTE that after the build, Vite will write the `index.html` (template)
|
|
98
|
+
// at the `/public/public/index.html` location. See `fs.renameSync` below.
|
|
99
|
+
input: paths.paths.appIndexHtml
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
server: {
|
|
103
|
+
port: DEFAULT_PORT
|
|
104
|
+
},
|
|
105
|
+
experimental: {
|
|
106
|
+
// https://vitejs.dev/guide/build.html#advanced-base-options
|
|
107
|
+
renderBuiltUrl: function renderBuiltUrl(filename, _ref) {
|
|
108
|
+
var hostType = _ref.hostType;
|
|
109
|
+
|
|
110
|
+
if (hostType === 'html') {
|
|
111
|
+
return "__CDN_URL__".concat(filename);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
runtime: "window.__toCdnUrl(".concat(_JSON$stringify__default["default"](filename), ")")
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
plugins: [pluginGraphql__default["default"](), pluginReact__default["default"]({
|
|
120
|
+
jsxImportSource: '@emotion/react',
|
|
121
|
+
babel: {
|
|
122
|
+
plugins: ['@emotion/babel-plugin']
|
|
123
|
+
}
|
|
124
|
+
}), vitePluginSvgr.vitePluginSvgr(), vitePluginDynamicBaseAssetsGlobals()]
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
case 7:
|
|
128
|
+
// Rename `/public/public/index.html` to `/public/index.html.template`
|
|
129
|
+
fs__default["default"].renameSync( // Because of our custom entry point path (`/public/index.html`),
|
|
130
|
+
// Vite will write the `index.html` to `/public/public/index.html`.
|
|
131
|
+
// We need to move this file to the `/public` folder and rename it
|
|
132
|
+
// to `index.html.template` (as expected by the `compile-html` command).
|
|
133
|
+
path__default["default"].join(paths.paths.appBuild, 'public/index.html'), paths.paths.appIndexHtmlTemplate); // Clean up nested folder
|
|
134
|
+
|
|
135
|
+
fs__default["default"].rmdirSync(path__default["default"].join(paths.paths.appBuild, 'public')); // Copy public assets
|
|
136
|
+
|
|
137
|
+
fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
|
|
138
|
+
dereference: true
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
case 10:
|
|
142
|
+
case "end":
|
|
143
|
+
return _context.stop();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, _callee);
|
|
147
|
+
}));
|
|
148
|
+
return _run.apply(this, arguments);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
exports["default"] = run;
|