@umijs/bundler-webpack 4.0.7 → 4.0.10

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.
Files changed (69) hide show
  1. package/{dist → client}/client/client.d.ts +0 -0
  2. package/client/client/client.js +295 -194
  3. package/client/constants.d.ts +15 -0
  4. package/client/constants.js +28 -19
  5. package/client/utils/formatWebpackMessages.d.ts +12 -0
  6. package/client/utils/formatWebpackMessages.js +68 -86
  7. package/dist/build.d.ts +1 -1
  8. package/dist/build.js +105 -68
  9. package/dist/cli.js +77 -69
  10. package/dist/config/_sampleFeature.js +33 -9
  11. package/dist/config/assetRules.js +45 -36
  12. package/dist/config/bundleAnalyzerPlugin.js +39 -17
  13. package/dist/config/compressPlugin.js +114 -95
  14. package/dist/config/config.d.ts +1 -0
  15. package/dist/config/config.js +204 -215
  16. package/dist/config/copyPlugin.js +59 -40
  17. package/dist/config/cssRules.js +136 -131
  18. package/dist/config/definePlugin.js +71 -35
  19. package/dist/config/detectDeadCode.js +120 -108
  20. package/dist/config/detectDeadCodePlugin.js +78 -63
  21. package/dist/config/fastRefreshPlugin.js +39 -20
  22. package/dist/config/forkTSCheckerPlugin.js +38 -19
  23. package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
  24. package/dist/config/ignorePlugin.js +38 -14
  25. package/dist/config/javaScriptRules.js +147 -173
  26. package/dist/config/manifestPlugin.js +51 -15
  27. package/dist/config/miniCSSExtractPlugin.js +42 -22
  28. package/dist/config/nodePolyfill.js +65 -26
  29. package/dist/config/nodePrefixPlugin.js +36 -12
  30. package/dist/config/progressPlugin.js +37 -13
  31. package/dist/config/purgecssWebpackPlugin.js +41 -19
  32. package/dist/config/speedMeasureWebpackPlugin.js +41 -20
  33. package/dist/config/ssrPlugin.js +83 -63
  34. package/dist/config/svgRules.js +74 -46
  35. package/dist/constants.js +57 -22
  36. package/dist/dev.d.ts +1 -1
  37. package/dist/dev.js +174 -134
  38. package/dist/index.js +22 -20
  39. package/dist/loader/svgr.js +73 -54
  40. package/dist/loader/swc.js +110 -69
  41. package/dist/parcelCSS.js +31 -27
  42. package/dist/plugins/ProgressPlugin.js +66 -43
  43. package/dist/plugins/RuntimePublicPathPlugin.js +42 -23
  44. package/dist/plugins/_SamplePlugin.js +39 -14
  45. package/dist/requireHook.js +37 -27
  46. package/dist/schema.js +123 -96
  47. package/dist/server/server.d.ts +0 -1
  48. package/dist/server/server.js +214 -184
  49. package/dist/server/ws.d.ts +0 -2
  50. package/dist/server/ws.js +63 -38
  51. package/dist/swcPlugins/autoCSSModules.js +50 -31
  52. package/dist/swcPlugins/changeImportFromString.js +31 -9
  53. package/dist/swcPlugins/lockCoreJS.js +44 -20
  54. package/dist/types.d.ts +2 -1
  55. package/dist/types.js +61 -30
  56. package/dist/utils/browsersList.js +31 -8
  57. package/dist/utils/depMatch.js +63 -39
  58. package/dist/utils/formatWebpackMessages.js +93 -91
  59. package/dist/utils/getEsBuildTarget.d.ts +3 -1
  60. package/dist/utils/getEsBuildTarget.js +39 -11
  61. package/package.json +12 -16
  62. package/compiled/fork-ts-checker-webpack-plugin/LICENSE +0 -21
  63. package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
  64. package/compiled/fork-ts-checker-webpack-plugin/index.js +0 -42
  65. package/compiled/fork-ts-checker-webpack-plugin/package.json +0 -1
  66. package/compiled/react-refresh/LICENSE +0 -21
  67. package/compiled/react-refresh/index.js +0 -21
  68. package/compiled/react-refresh/package.json +0 -1
  69. package/dist/client/client.js +0 -245
@@ -1,92 +1,74 @@
1
- import stripAnsi from '@umijs/utils/compiled/strip-ansi';
2
- const friendlySyntaxErrorLabel = 'Syntax error:';
1
+ // src/utils/formatWebpackMessages.ts
2
+ import stripAnsi from "@umijs/utils/compiled/strip-ansi";
3
+ var friendlySyntaxErrorLabel = "Syntax error:";
3
4
  function isLikelyASyntaxError(message) {
4
- return stripAnsi(message).indexOf(friendlySyntaxErrorLabel) !== -1;
5
+ return stripAnsi(message).indexOf(friendlySyntaxErrorLabel) !== -1;
5
6
  }
6
- export function formatMessage(message) {
7
- let lines = [];
8
- if (typeof message === 'string') {
9
- lines = message.split('\n');
10
- }
11
- else if ('message' in message) {
12
- lines = message['message'].split('\n');
13
- }
14
- else if (Array.isArray(message)) {
15
- message.forEach((message) => {
16
- if ('message' in message) {
17
- lines = message['message'].split('\n');
18
- }
19
- });
20
- }
21
- // Strip webpack-added headers off errors/warnings
22
- // https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
23
- lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
24
- // Transform parsing error into syntax error
25
- // TODO: move this to our ESLint formatter?
26
- lines = lines.map((line) => {
27
- const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
28
- if (!parsingError) {
29
- return line;
30
- }
31
- const [, errorLine, errorColumn, errorMessage] = parsingError;
32
- return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
7
+ function formatMessage(message) {
8
+ let lines = [];
9
+ if (typeof message === "string") {
10
+ lines = message.split("\n");
11
+ } else if ("message" in message) {
12
+ lines = message["message"].split("\n");
13
+ } else if (Array.isArray(message)) {
14
+ message.forEach((message2) => {
15
+ if ("message" in message2) {
16
+ lines = message2["message"].split("\n");
17
+ }
33
18
  });
34
- message = lines.join('\n');
35
- // Smoosh syntax errors (commonly found in CSS)
36
- message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, `${friendlySyntaxErrorLabel} $3 ($1:$2)\n`);
37
- // Clean up export errors
38
- message = message.replace(/^.*export '(.+?)' was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$2'.`);
39
- message = message.replace(/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$2' does not contain a default export (imported as '$1').`);
40
- message = message.replace(/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$3' (imported as '$2').`);
41
- lines = message.split('\n');
42
- // Remove leading newline
43
- if (lines.length > 2 && lines[1].trim() === '') {
44
- lines.splice(1, 1);
45
- }
46
- // Clean up file name
47
- lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1');
48
- // Cleans up verbose "module not found" messages for files and packages.
49
- if (lines[1] && lines[1].indexOf('Module not found: ') === 0) {
50
- lines = [
51
- lines[0],
52
- lines[1]
53
- .replace('Error: ', '')
54
- .replace('Module not found: Cannot find file:', 'Cannot find file:'),
55
- ];
19
+ }
20
+ lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
21
+ lines = lines.map((line) => {
22
+ const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
23
+ if (!parsingError) {
24
+ return line;
56
25
  }
57
- // Add helpful message for users trying to use Sass for the first time
58
- if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
59
- lines[1] = 'To import Sass files, you first need to install sass.\n';
60
- lines[1] +=
61
- 'Run `npm install sass` or `yarn add sass` inside your workspace.';
62
- }
63
- message = lines.join('\n');
64
- // Internal stacks are generally useless so we strip them... with the
65
- // exception of stacks containing `webpack:` because they're normally
66
- // from user code generated by webpack. For more information see
67
- // https://github.com/facebook/create-react-app/pull/1050
68
- message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, ''); // at ... ...:x:y
69
- message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, ''); // at <anonymous>
70
- lines = message.split('\n');
71
- // Remove duplicated newlines
72
- lines = lines.filter((line, index, arr) => index === 0 ||
73
- line.trim() !== '' ||
74
- line.trim() !== arr[index - 1].trim());
75
- // Reassemble the message
76
- message = lines.join('\n');
77
- return message.trim();
26
+ const [, errorLine, errorColumn, errorMessage] = parsingError;
27
+ return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
28
+ });
29
+ message = lines.join("\n");
30
+ message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, `${friendlySyntaxErrorLabel} $3 ($1:$2)
31
+ `);
32
+ message = message.replace(/^.*export '(.+?)' was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$2'.`);
33
+ message = message.replace(/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$2' does not contain a default export (imported as '$1').`);
34
+ message = message.replace(/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$3' (imported as '$2').`);
35
+ lines = message.split("\n");
36
+ if (lines.length > 2 && lines[1].trim() === "") {
37
+ lines.splice(1, 1);
38
+ }
39
+ lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
40
+ if (lines[1] && lines[1].indexOf("Module not found: ") === 0) {
41
+ lines = [
42
+ lines[0],
43
+ lines[1].replace("Error: ", "").replace("Module not found: Cannot find file:", "Cannot find file:")
44
+ ];
45
+ }
46
+ if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
47
+ lines[1] = "To import Sass files, you first need to install sass.\n";
48
+ lines[1] += "Run `npm install sass` or `yarn add sass` inside your workspace.";
49
+ }
50
+ message = lines.join("\n");
51
+ message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, "");
52
+ message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "");
53
+ lines = message.split("\n");
54
+ lines = lines.filter((line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim());
55
+ message = lines.join("\n");
56
+ return message.trim();
78
57
  }
79
- export function formatWebpackMessages(json) {
80
- const formattedErrors = json.errors.map(function (message) {
81
- return formatMessage(message);
82
- });
83
- const formattedWarnings = json.warnings.map(function (message) {
84
- return formatMessage(message);
85
- });
86
- const result = { errors: formattedErrors, warnings: formattedWarnings };
87
- if (result.errors.some(isLikelyASyntaxError)) {
88
- // If there are any syntax errors, show just them.
89
- result.errors = result.errors.filter(isLikelyASyntaxError);
90
- }
91
- return result;
58
+ function formatWebpackMessages(json) {
59
+ const formattedErrors = json.errors.map(function(message) {
60
+ return formatMessage(message);
61
+ });
62
+ const formattedWarnings = json.warnings.map(function(message) {
63
+ return formatMessage(message);
64
+ });
65
+ const result = { errors: formattedErrors, warnings: formattedWarnings };
66
+ if (result.errors.some(isLikelyASyntaxError)) {
67
+ result.errors = result.errors.filter(isLikelyASyntaxError);
68
+ }
69
+ return result;
92
70
  }
71
+ export {
72
+ formatMessage,
73
+ formatWebpackMessages
74
+ };
package/dist/build.d.ts CHANGED
@@ -15,6 +15,6 @@ declare type IOpts = {
15
15
  extraBabelPlugins?: any[];
16
16
  extraBabelPresets?: any[];
17
17
  clean?: boolean;
18
- } & Pick<IConfigOpts, 'cache'>;
18
+ } & Pick<IConfigOpts, 'cache' | 'pkg'>;
19
19
  export declare function build(opts: IOpts): Promise<webpack.Stats>;
20
20
  export {};
package/dist/build.js CHANGED
@@ -1,73 +1,110 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
4
22
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.build = void 0;
7
- const utils_1 = require("@umijs/utils");
8
- const path_1 = require("path");
9
- const webpack_1 = __importDefault(require("../compiled/webpack"));
10
- const config_1 = require("./config/config");
11
- const types_1 = require("./types");
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+
39
+ // src/build.ts
40
+ var build_exports = {};
41
+ __export(build_exports, {
42
+ build: () => build
43
+ });
44
+ module.exports = __toCommonJS(build_exports);
45
+ var import_utils = require("@umijs/utils");
46
+ var import_path = require("path");
47
+ var import_webpack = __toESM(require("../compiled/webpack"));
48
+ var import_config = require("./config/config");
49
+ var import_types = require("./types");
12
50
  async function build(opts) {
13
- const cacheDirectoryPath = (0, path_1.resolve)(opts.rootDir || opts.cwd, opts.config.cacheDirectoryPath || 'node_modules/.cache');
14
- const webpackConfig = await (0, config_1.getConfig)({
15
- cwd: opts.cwd,
16
- rootDir: opts.rootDir,
17
- env: types_1.Env.production,
18
- entry: opts.entry,
19
- userConfig: opts.config,
20
- analyze: process.env.ANALYZE,
21
- babelPreset: opts.babelPreset,
22
- extraBabelPlugins: [
23
- ...(opts.beforeBabelPlugins || []),
24
- ...(opts.extraBabelPlugins || []),
25
- ],
26
- extraBabelPresets: [
27
- ...(opts.beforeBabelPresets || []),
28
- ...(opts.extraBabelPresets || []),
29
- ],
30
- extraBabelIncludes: opts.config.extraBabelIncludes,
31
- chainWebpack: opts.chainWebpack,
32
- modifyWebpackConfig: opts.modifyWebpackConfig,
33
- cache: opts.cache
34
- ? {
35
- ...opts.cache,
36
- cacheDirectory: (0, path_1.join)(cacheDirectoryPath, 'bundler-webpack'),
37
- }
38
- : undefined,
39
- });
40
- let isFirstCompile = true;
41
- return new Promise((resolve, reject) => {
42
- if (opts.clean) {
43
- utils_1.rimraf.sync(webpackConfig.output.path);
51
+ const cacheDirectoryPath = (0, import_path.resolve)(opts.rootDir || opts.cwd, opts.config.cacheDirectoryPath || "node_modules/.cache");
52
+ const webpackConfig = await (0, import_config.getConfig)({
53
+ cwd: opts.cwd,
54
+ rootDir: opts.rootDir,
55
+ env: import_types.Env.production,
56
+ entry: opts.entry,
57
+ userConfig: opts.config,
58
+ analyze: process.env.ANALYZE,
59
+ babelPreset: opts.babelPreset,
60
+ extraBabelPlugins: [
61
+ ...opts.beforeBabelPlugins || [],
62
+ ...opts.extraBabelPlugins || []
63
+ ],
64
+ extraBabelPresets: [
65
+ ...opts.beforeBabelPresets || [],
66
+ ...opts.extraBabelPresets || []
67
+ ],
68
+ extraBabelIncludes: opts.config.extraBabelIncludes,
69
+ chainWebpack: opts.chainWebpack,
70
+ modifyWebpackConfig: opts.modifyWebpackConfig,
71
+ cache: opts.cache ? __spreadProps(__spreadValues({}, opts.cache), {
72
+ cacheDirectory: (0, import_path.join)(cacheDirectoryPath, "bundler-webpack")
73
+ }) : void 0,
74
+ pkg: opts.pkg
75
+ });
76
+ let isFirstCompile = true;
77
+ return new Promise((resolve2, reject) => {
78
+ if (opts.clean) {
79
+ import_utils.rimraf.sync(webpackConfig.output.path);
80
+ }
81
+ const compiler = (0, import_webpack.default)(webpackConfig);
82
+ compiler.run((err, stats) => {
83
+ var _a;
84
+ (_a = opts.onBuildComplete) == null ? void 0 : _a.call(opts, {
85
+ err,
86
+ stats,
87
+ isFirstCompile,
88
+ time: stats ? stats.endTime - stats.startTime : null
89
+ });
90
+ isFirstCompile = false;
91
+ if (err || (stats == null ? void 0 : stats.hasErrors())) {
92
+ if (err) {
93
+ reject(err);
94
+ }
95
+ if (stats) {
96
+ const errorMsg = stats.toString("errors-only");
97
+ reject(new Error(errorMsg));
44
98
  }
45
- const compiler = (0, webpack_1.default)(webpackConfig);
46
- compiler.run((err, stats) => {
47
- var _a;
48
- (_a = opts.onBuildComplete) === null || _a === void 0 ? void 0 : _a.call(opts, {
49
- err,
50
- stats,
51
- isFirstCompile,
52
- time: stats ? stats.endTime - stats.startTime : null,
53
- });
54
- isFirstCompile = false;
55
- if (err || (stats === null || stats === void 0 ? void 0 : stats.hasErrors())) {
56
- if (err) {
57
- // console.error(err);
58
- reject(err);
59
- }
60
- if (stats) {
61
- const errorMsg = stats.toString('errors-only');
62
- // console.error(errorMsg);
63
- reject(new Error(errorMsg));
64
- }
65
- }
66
- else {
67
- resolve(stats);
68
- }
69
- compiler.close(() => { });
70
- });
99
+ } else {
100
+ resolve2(stats);
101
+ }
102
+ compiler.close(() => {
103
+ });
71
104
  });
105
+ });
72
106
  }
73
- exports.build = build;
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ build
110
+ });
package/dist/cli.js CHANGED
@@ -1,81 +1,89 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
4
14
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const esbuild_1 = __importDefault(require("@umijs/bundler-utils/compiled/esbuild"));
7
- const utils_1 = require("@umijs/utils");
8
- const assert_1 = __importDefault(require("assert"));
9
- const fs_1 = require("fs");
10
- const path_1 = require("path");
11
- const build_1 = require("./build");
12
- const dev_1 = require("./dev");
13
- const args = (0, utils_1.yParser)(process.argv.slice(2), {});
14
- const command = args._[0];
15
- const cwd = process.cwd();
16
- const entry = (0, utils_1.tryPaths)([
17
- (0, path_1.join)(cwd, 'src/index.tsx'),
18
- (0, path_1.join)(cwd, 'src/index.ts'),
19
- (0, path_1.join)(cwd, 'index.tsx'),
20
- (0, path_1.join)(cwd, 'index.ts'),
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
16
+
17
+ // src/cli.ts
18
+ var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
19
+ var import_utils = require("@umijs/utils");
20
+ var import_assert = __toESM(require("assert"));
21
+ var import_fs = require("fs");
22
+ var import_path = require("path");
23
+ var import_build = require("./build");
24
+ var import_dev = require("./dev");
25
+ var args = (0, import_utils.yParser)(process.argv.slice(2), {});
26
+ var command = args._[0];
27
+ var cwd = process.cwd();
28
+ var entry = (0, import_utils.tryPaths)([
29
+ (0, import_path.join)(cwd, "src/index.tsx"),
30
+ (0, import_path.join)(cwd, "src/index.ts"),
31
+ (0, import_path.join)(cwd, "index.tsx"),
32
+ (0, import_path.join)(cwd, "index.ts")
21
33
  ]);
22
- let config = {};
23
- const configFile = (0, path_1.join)(cwd, args.config || 'config.ts');
24
- utils_1.register.register({
25
- implementor: esbuild_1.default,
34
+ var config = {};
35
+ var configFile = (0, import_path.join)(cwd, args.config || "config.ts");
36
+ import_utils.register.register({
37
+ implementor: import_esbuild.default
26
38
  });
27
- utils_1.register.clearFiles();
28
- if ((0, fs_1.existsSync)(configFile)) {
29
- require('./requireHook');
30
- config = require(configFile).default;
39
+ import_utils.register.clearFiles();
40
+ if ((0, import_fs.existsSync)(configFile)) {
41
+ require("./requireHook");
42
+ config = require(configFile).default;
31
43
  }
32
44
  Object.assign(config, args);
33
- if (command === 'build') {
34
- (async () => {
35
- process.env.NODE_ENV = 'production';
36
- (0, assert_1.default)(entry, `Build failed: entry not found.`);
37
- try {
38
- await (0, build_1.build)({
39
- config,
40
- cwd,
41
- entry: {
42
- [getEntryKey(entry)]: entry,
43
- },
44
- });
45
+ if (command === "build") {
46
+ (async () => {
47
+ process.env.NODE_ENV = "production";
48
+ (0, import_assert.default)(entry, `Build failed: entry not found.`);
49
+ try {
50
+ await (0, import_build.build)({
51
+ config,
52
+ cwd,
53
+ entry: {
54
+ [getEntryKey(entry)]: entry
45
55
  }
46
- catch (e) {
47
- console.error(e);
56
+ });
57
+ } catch (e) {
58
+ console.error(e);
59
+ }
60
+ })();
61
+ } else if (command === "dev") {
62
+ (async () => {
63
+ process.env.NODE_ENV = "development";
64
+ try {
65
+ (0, import_assert.default)(entry, `Build failed: entry not found.`);
66
+ await (0, import_dev.dev)({
67
+ config,
68
+ cwd,
69
+ port: process.env.PORT,
70
+ entry: {
71
+ [getEntryKey(entry)]: entry
72
+ },
73
+ cache: {
74
+ buildDependencies: [].filter(Boolean)
48
75
  }
49
- })();
50
- }
51
- else if (command === 'dev') {
52
- (async () => {
53
- process.env.NODE_ENV = 'development';
54
- try {
55
- (0, assert_1.default)(entry, `Build failed: entry not found.`);
56
- await (0, dev_1.dev)({
57
- config,
58
- cwd,
59
- port: process.env.PORT,
60
- entry: {
61
- [getEntryKey(entry)]: entry,
62
- },
63
- cache: {
64
- buildDependencies: [].filter(Boolean),
65
- },
66
- });
67
- }
68
- catch (e) {
69
- console.error(e);
70
- }
71
- })();
72
- }
73
- else {
74
- error(`Unsupported command ${command}.`);
76
+ });
77
+ } catch (e) {
78
+ console.error(e);
79
+ }
80
+ })();
81
+ } else {
82
+ error(`Unsupported command ${command}.`);
75
83
  }
76
84
  function error(msg) {
77
- console.error(utils_1.chalk.red(msg));
85
+ console.error(import_utils.chalk.red(msg));
78
86
  }
79
87
  function getEntryKey(path) {
80
- return (0, path_1.basename)(path, (0, path_1.extname)(path));
88
+ return (0, import_path.basename)(path, (0, import_path.extname)(path));
81
89
  }
@@ -1,11 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addSampleFeature = void 0;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/config/_sampleFeature.ts
20
+ var sampleFeature_exports = {};
21
+ __export(sampleFeature_exports, {
22
+ addSampleFeature: () => addSampleFeature
23
+ });
24
+ module.exports = __toCommonJS(sampleFeature_exports);
4
25
  async function addSampleFeature(opts) {
5
- const { config, userConfig, cwd, env } = opts;
6
- config;
7
- userConfig;
8
- cwd;
9
- env;
26
+ const { config, userConfig, cwd, env } = opts;
27
+ config;
28
+ userConfig;
29
+ cwd;
30
+ env;
10
31
  }
11
- exports.addSampleFeature = addSampleFeature;
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ addSampleFeature
35
+ });
@@ -1,39 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addAssetRules = void 0;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/config/assetRules.ts
20
+ var assetRules_exports = {};
21
+ __export(assetRules_exports, {
22
+ addAssetRules: () => addAssetRules
23
+ });
24
+ module.exports = __toCommonJS(assetRules_exports);
4
25
  async function addAssetRules(opts) {
5
- const { config, userConfig } = opts;
6
- const inlineLimit = parseInt(userConfig.inlineLimit || '10000', 10);
7
- const rule = config.module.rule('asset');
8
- rule
9
- .oneOf('avif')
10
- .test(/\.avif$/)
11
- .type('asset')
12
- .mimetype('image/avif')
13
- .parser({
14
- dataUrlCondition: {
15
- maxSize: inlineLimit,
16
- },
17
- });
18
- rule
19
- .oneOf('image')
20
- .test(/\.(bmp|gif|jpg|jpeg|png)$/)
21
- .type('asset')
22
- .parser({
23
- dataUrlCondition: {
24
- maxSize: inlineLimit,
25
- },
26
- });
27
- const fallback = rule
28
- .oneOf('fallback')
29
- .exclude.add(/^$/) /* handle data: resources */
30
- .add(/\.(js|mjs|jsx|ts|tsx)$/)
31
- .add(/\.(css|less|sass|scss|stylus)$/)
32
- .add(/\.html$/)
33
- .add(/\.json$/);
34
- if (userConfig.mdx) {
35
- fallback.add(/\.mdx?$/);
26
+ const { config, userConfig } = opts;
27
+ const inlineLimit = parseInt(userConfig.inlineLimit || "10000", 10);
28
+ const rule = config.module.rule("asset");
29
+ rule.oneOf("avif").test(/\.avif$/).type("asset").mimetype("image/avif").parser({
30
+ dataUrlCondition: {
31
+ maxSize: inlineLimit
36
32
  }
37
- fallback.end().type('asset/resource');
33
+ });
34
+ rule.oneOf("image").test(/\.(bmp|gif|jpg|jpeg|png)$/).type("asset").parser({
35
+ dataUrlCondition: {
36
+ maxSize: inlineLimit
37
+ }
38
+ });
39
+ const fallback = rule.oneOf("fallback").exclude.add(/^$/).add(/\.(js|mjs|jsx|ts|tsx)$/).add(/\.(css|less|sass|scss|stylus)$/).add(/\.html$/).add(/\.json$/);
40
+ if (userConfig.mdx) {
41
+ fallback.add(/\.mdx?$/);
42
+ }
43
+ fallback.end().type("asset/resource");
38
44
  }
39
- exports.addAssetRules = addAssetRules;
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ addAssetRules
48
+ });