@umijs/bundler-webpack 4.0.6 → 4.0.9
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/{dist → client}/client/client.d.ts +0 -0
- package/client/client/client.js +295 -194
- package/client/constants.d.ts +15 -0
- package/client/constants.js +28 -19
- package/client/utils/formatWebpackMessages.d.ts +12 -0
- package/client/utils/formatWebpackMessages.js +68 -86
- package/dist/build.d.ts +1 -1
- package/dist/build.js +105 -61
- package/dist/cli.js +77 -69
- package/dist/config/_sampleFeature.js +33 -9
- package/dist/config/assetRules.js +45 -36
- package/dist/config/bundleAnalyzerPlugin.js +39 -17
- package/dist/config/compressPlugin.js +113 -95
- package/dist/config/config.d.ts +1 -0
- package/dist/config/config.js +204 -215
- package/dist/config/copyPlugin.js +59 -40
- package/dist/config/cssRules.js +136 -131
- package/dist/config/definePlugin.d.ts +1 -0
- package/dist/config/definePlugin.js +71 -31
- package/dist/config/detectDeadCode.js +120 -108
- package/dist/config/detectDeadCodePlugin.js +78 -63
- package/dist/config/fastRefreshPlugin.js +39 -20
- package/dist/config/forkTSCheckerPlugin.js +38 -19
- package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
- package/dist/config/ignorePlugin.js +38 -14
- package/dist/config/javaScriptRules.js +147 -173
- package/dist/config/manifestPlugin.js +51 -15
- package/dist/config/miniCSSExtractPlugin.js +42 -22
- package/dist/config/nodePolyfill.js +65 -26
- package/dist/config/nodePrefixPlugin.js +36 -12
- package/dist/config/progressPlugin.js +37 -13
- package/dist/config/purgecssWebpackPlugin.js +41 -19
- package/dist/config/speedMeasureWebpackPlugin.js +41 -20
- package/dist/config/ssrPlugin.js +83 -63
- package/dist/config/svgRules.js +74 -46
- package/dist/constants.js +57 -22
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +170 -129
- package/dist/index.js +22 -20
- package/dist/loader/svgr.js +73 -54
- package/dist/loader/swc.js +110 -69
- package/dist/parcelCSS.js +31 -27
- package/dist/plugins/ProgressPlugin.js +66 -43
- package/dist/plugins/RuntimePublicPathPlugin.js +42 -23
- package/dist/plugins/_SamplePlugin.js +39 -14
- package/dist/requireHook.js +37 -27
- package/dist/schema.js +120 -95
- package/dist/server/server.d.ts +0 -1
- package/dist/server/server.js +214 -184
- package/dist/server/ws.d.ts +0 -2
- package/dist/server/ws.js +63 -38
- package/dist/swcPlugins/autoCSSModules.js +50 -31
- package/dist/swcPlugins/changeImportFromString.js +31 -9
- package/dist/swcPlugins/lockCoreJS.js +44 -20
- package/dist/types.d.ts +2 -1
- package/dist/types.js +61 -30
- package/dist/utils/browsersList.js +31 -8
- package/dist/utils/depMatch.js +63 -39
- package/dist/utils/formatWebpackMessages.js +93 -91
- package/dist/utils/getEsBuildTarget.js +32 -10
- package/package.json +12 -16
- package/compiled/fork-ts-checker-webpack-plugin/LICENSE +0 -21
- package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +0 -42
- package/compiled/fork-ts-checker-webpack-plugin/package.json +0 -1
- package/compiled/react-refresh/LICENSE +0 -21
- package/compiled/react-refresh/index.js +0 -21
- package/compiled/react-refresh/package.json +0 -1
- package/dist/client/client.js +0 -245
|
@@ -1,92 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// formatWebpackMessages.ts
|
|
2
|
+
import stripAnsi from "@umijs/utils/compiled/strip-ansi";
|
|
3
|
+
var friendlySyntaxErrorLabel = "Syntax error:";
|
|
3
4
|
function isLikelyASyntaxError(message) {
|
|
4
|
-
|
|
5
|
+
return stripAnsi(message).indexOf(friendlySyntaxErrorLabel) !== -1;
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
message.
|
|
16
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
lines =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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,66 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
// 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");
|
|
11
50
|
async function build(opts) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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));
|
|
37
98
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
stats,
|
|
44
|
-
isFirstCompile,
|
|
45
|
-
time: stats ? stats.endTime - stats.startTime : null,
|
|
46
|
-
});
|
|
47
|
-
isFirstCompile = false;
|
|
48
|
-
if (err || (stats === null || stats === void 0 ? void 0 : stats.hasErrors())) {
|
|
49
|
-
if (err) {
|
|
50
|
-
// console.error(err);
|
|
51
|
-
reject(err);
|
|
52
|
-
}
|
|
53
|
-
if (stats) {
|
|
54
|
-
const errorMsg = stats.toString('errors-only');
|
|
55
|
-
// console.error(errorMsg);
|
|
56
|
-
reject(new Error(errorMsg));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
resolve(stats);
|
|
61
|
-
}
|
|
62
|
-
compiler.close(() => { });
|
|
63
|
-
});
|
|
99
|
+
} else {
|
|
100
|
+
resolve2(stats);
|
|
101
|
+
}
|
|
102
|
+
compiler.close(() => {
|
|
103
|
+
});
|
|
64
104
|
});
|
|
105
|
+
});
|
|
65
106
|
}
|
|
66
|
-
|
|
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
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
// 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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
28
|
-
if ((0,
|
|
29
|
-
|
|
30
|
-
|
|
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 ===
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
47
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
85
|
+
console.error(import_utils.chalk.red(msg));
|
|
78
86
|
}
|
|
79
87
|
function getEntryKey(path) {
|
|
80
|
-
|
|
88
|
+
return (0, import_path.basename)(path, (0, import_path.extname)(path));
|
|
81
89
|
}
|
|
@@ -1,11 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
// _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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
26
|
+
const { config, userConfig, cwd, env } = opts;
|
|
27
|
+
config;
|
|
28
|
+
userConfig;
|
|
29
|
+
cwd;
|
|
30
|
+
env;
|
|
10
31
|
}
|
|
11
|
-
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
addSampleFeature
|
|
35
|
+
});
|
|
@@ -1,39 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
// 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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
addAssetRules
|
|
48
|
+
});
|