@modern-js/app-tools 2.0.0-beta.2 → 2.0.0-beta.4
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/CHANGELOG.md +556 -0
- package/bin/modern.js +11 -1
- package/dist/js/modern/analyze/Builder.js +39 -0
- package/dist/js/modern/analyze/constants.js +38 -16
- package/dist/js/modern/analyze/generateCode.js +272 -211
- package/dist/js/modern/analyze/getBundleEntry.js +34 -32
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +93 -49
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +89 -47
- package/dist/js/modern/analyze/getClientRoutes/index.js +6 -2
- package/dist/js/modern/analyze/getClientRoutes/utils.js +23 -10
- package/dist/js/modern/analyze/getFileSystemEntry.js +43 -22
- package/dist/js/modern/analyze/getHtmlTemplate.js +89 -49
- package/dist/js/modern/analyze/getServerRoutes.js +122 -126
- package/dist/js/modern/analyze/index.js +201 -160
- package/dist/js/modern/analyze/isDefaultExportFunction.js +30 -16
- package/dist/js/modern/analyze/makeLegalIdentifier.js +10 -11
- package/dist/js/modern/analyze/nestedRoutes.js +110 -53
- package/dist/js/modern/analyze/templates.js +191 -77
- package/dist/js/modern/analyze/utils.js +98 -51
- package/dist/js/modern/builder/builderPlugins/compatModern.js +125 -107
- package/dist/js/modern/builder/index.js +124 -89
- package/dist/js/modern/builder/loaders/routerLoader.js +17 -0
- package/dist/js/modern/builder/loaders/serverModuleLoader.js +7 -0
- package/dist/js/modern/builder/share.js +23 -21
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +23 -22
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +31 -27
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +100 -84
- package/dist/js/modern/commands/build.js +67 -42
- package/dist/js/modern/commands/deploy.js +27 -4
- package/dist/js/modern/commands/dev.js +93 -47
- package/dist/js/modern/commands/index.js +1 -1
- package/dist/js/modern/commands/inspect.js +30 -5
- package/dist/js/modern/commands/start.js +37 -16
- package/dist/js/modern/config/default.js +103 -114
- package/dist/js/modern/config/index.js +8 -2
- package/dist/js/modern/config/initial/createHtmlConfig.js +5 -2
- package/dist/js/modern/config/initial/createOutputConfig.js +11 -9
- package/dist/js/modern/config/initial/createSourceConfig.js +5 -2
- package/dist/js/modern/config/initial/createToolsConfig.js +7 -6
- package/dist/js/modern/config/initial/index.js +9 -4
- package/dist/js/modern/config/initial/inits.js +109 -73
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +6 -3
- package/dist/js/modern/defineConfig.js +26 -11
- package/dist/js/modern/exports/server.js +4 -1
- package/dist/js/modern/hooks.js +15 -4
- package/dist/js/modern/index.js +178 -90
- package/dist/js/modern/initialize/index.js +98 -51
- package/dist/js/modern/locale/en.js +20 -21
- package/dist/js/modern/locale/index.js +6 -6
- package/dist/js/modern/locale/zh.js +21 -22
- package/dist/js/modern/schema/Schema.js +6 -5
- package/dist/js/modern/schema/index.js +51 -100
- package/dist/js/modern/schema/legacy.js +96 -231
- package/dist/js/modern/types/config/index.js +0 -1
- package/dist/js/modern/types/index.js +0 -1
- package/dist/js/modern/types/legacyConfig/output.js +0 -1
- package/dist/js/modern/utils/commands.js +5 -2
- package/dist/js/modern/utils/config.js +102 -41
- package/dist/js/modern/utils/createFileWatcher.js +84 -51
- package/dist/js/modern/utils/createServer.js +63 -17
- package/dist/js/modern/utils/getSpecifiedEntries.js +46 -19
- package/dist/js/modern/utils/language.js +6 -3
- package/dist/js/modern/utils/printInstructions.js +27 -8
- package/dist/js/modern/utils/restart.js +43 -16
- package/dist/js/modern/utils/routes.js +29 -12
- package/dist/js/node/analyze/Builder.js +58 -0
- package/dist/js/node/analyze/constants.js +54 -35
- package/dist/js/node/analyze/generateCode.js +291 -228
- package/dist/js/node/analyze/getBundleEntry.js +58 -44
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +132 -76
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +128 -74
- package/dist/js/node/analyze/getClientRoutes/index.js +23 -17
- package/dist/js/node/analyze/getClientRoutes/utils.js +44 -21
- package/dist/js/node/analyze/getFileSystemEntry.js +70 -39
- package/dist/js/node/analyze/getHtmlTemplate.js +116 -61
- package/dist/js/node/analyze/getServerRoutes.js +143 -137
- package/dist/js/node/analyze/index.js +247 -174
- package/dist/js/node/analyze/isDefaultExportFunction.js +55 -26
- package/dist/js/node/analyze/makeLegalIdentifier.js +27 -15
- package/dist/js/node/analyze/nestedRoutes.js +140 -67
- package/dist/js/node/analyze/templates.js +212 -84
- package/dist/js/node/analyze/utils.js +123 -62
- package/dist/js/node/builder/builderPlugins/compatModern.js +153 -120
- package/dist/js/node/builder/index.js +152 -98
- package/dist/js/node/builder/loaders/routerLoader.js +36 -0
- package/dist/js/node/builder/loaders/serverModuleLoader.js +26 -0
- package/dist/js/node/builder/share.js +46 -26
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +39 -26
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +47 -31
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +118 -90
- package/dist/js/node/commands/build.js +89 -52
- package/dist/js/node/commands/deploy.js +45 -10
- package/dist/js/node/commands/dev.js +115 -61
- package/dist/js/node/commands/index.js +19 -38
- package/dist/js/node/commands/inspect.js +48 -11
- package/dist/js/node/commands/start.js +65 -27
- package/dist/js/node/config/default.js +119 -118
- package/dist/js/node/config/index.js +25 -29
- package/dist/js/node/config/initial/createHtmlConfig.js +22 -6
- package/dist/js/node/config/initial/createOutputConfig.js +28 -13
- package/dist/js/node/config/initial/createSourceConfig.js +22 -6
- package/dist/js/node/config/initial/createToolsConfig.js +24 -10
- package/dist/js/node/config/initial/index.js +28 -17
- package/dist/js/node/config/initial/inits.js +126 -81
- package/dist/js/node/config/initial/transformNormalizedConfig.js +31 -15
- package/dist/js/node/defineConfig.js +43 -17
- package/dist/js/node/exports/server.js +21 -10
- package/dist/js/node/hooks.js +48 -29
- package/dist/js/node/index.js +225 -128
- package/dist/js/node/initialize/index.js +116 -61
- package/dist/js/node/locale/en.js +36 -25
- package/dist/js/node/locale/index.js +27 -15
- package/dist/js/node/locale/zh.js +37 -26
- package/dist/js/node/schema/Schema.js +23 -10
- package/dist/js/node/schema/index.js +77 -114
- package/dist/js/node/schema/legacy.js +117 -240
- package/dist/js/node/types/config/index.js +17 -16
- package/dist/js/node/types/index.js +19 -38
- package/dist/js/node/types/legacyConfig/output.js +0 -5
- package/dist/js/node/utils/commands.js +21 -6
- package/dist/js/node/utils/config.js +120 -51
- package/dist/js/node/utils/createFileWatcher.js +104 -60
- package/dist/js/node/utils/createServer.js +86 -25
- package/dist/js/node/utils/getSpecifiedEntries.js +64 -25
- package/dist/js/node/utils/language.js +24 -8
- package/dist/js/node/utils/printInstructions.js +47 -16
- package/dist/js/node/utils/restart.js +61 -21
- package/dist/js/node/utils/routes.js +53 -18
- package/dist/js/treeshaking/analyze/Builder.js +199 -0
- package/dist/js/treeshaking/analyze/constants.js +28 -16
- package/dist/js/treeshaking/analyze/generateCode.js +605 -355
- package/dist/js/treeshaking/analyze/getBundleEntry.js +55 -63
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +214 -168
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +215 -169
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -2
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +19 -20
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +89 -86
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +298 -125
- package/dist/js/treeshaking/analyze/getServerRoutes.js +210 -146
- package/dist/js/treeshaking/analyze/index.js +571 -304
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +45 -26
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -16
- package/dist/js/treeshaking/analyze/nestedRoutes.js +414 -160
- package/dist/js/treeshaking/analyze/templates.js +432 -161
- package/dist/js/treeshaking/analyze/utils.js +361 -80
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +282 -195
- package/dist/js/treeshaking/builder/index.js +371 -167
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +13 -0
- package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +5 -0
- package/dist/js/treeshaking/builder/share.js +38 -44
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +108 -44
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +70 -39
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +334 -112
- package/dist/js/treeshaking/commands/build.js +286 -88
- package/dist/js/treeshaking/commands/deploy.js +153 -25
- package/dist/js/treeshaking/commands/dev.js +318 -132
- package/dist/js/treeshaking/commands/index.js +1 -1
- package/dist/js/treeshaking/commands/inspect.js +147 -32
- package/dist/js/treeshaking/commands/start.js +190 -68
- package/dist/js/treeshaking/config/default.js +210 -199
- package/dist/js/treeshaking/config/index.js +3 -2
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +19 -31
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +43 -67
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +37 -40
- package/dist/js/treeshaking/config/initial/createToolsConfig.js +23 -38
- package/dist/js/treeshaking/config/initial/index.js +10 -9
- package/dist/js/treeshaking/config/initial/inits.js +205 -106
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +27 -34
- package/dist/js/treeshaking/defineConfig.js +60 -13
- package/dist/js/treeshaking/exports/server.js +2 -1
- package/dist/js/treeshaking/hooks.js +30 -25
- package/dist/js/treeshaking/index.js +681 -256
- package/dist/js/treeshaking/initialize/index.js +290 -112
- package/dist/js/treeshaking/locale/en.js +34 -33
- package/dist/js/treeshaking/locale/index.js +5 -5
- package/dist/js/treeshaking/locale/zh.js +34 -33
- package/dist/js/treeshaking/schema/Schema.js +267 -69
- package/dist/js/treeshaking/schema/index.js +165 -121
- package/dist/js/treeshaking/schema/legacy.js +323 -256
- package/dist/js/treeshaking/types/config/deploy.js +1 -0
- package/dist/js/treeshaking/types/config/dev.js +1 -0
- package/dist/js/treeshaking/types/config/experiments.js +1 -0
- package/dist/js/treeshaking/types/config/html.js +1 -0
- package/dist/js/treeshaking/types/config/index.js +0 -1
- package/dist/js/treeshaking/types/config/output.js +1 -0
- package/dist/js/treeshaking/types/config/performance.js +1 -0
- package/dist/js/treeshaking/types/config/security.js +1 -0
- package/dist/js/treeshaking/types/config/source.js +1 -0
- package/dist/js/treeshaking/types/config/tools.js +1 -0
- package/dist/js/treeshaking/types/hooks.js +1 -0
- package/dist/js/treeshaking/types/index.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/output.js +1 -1
- package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
- package/dist/js/treeshaking/utils/commands.js +6 -5
- package/dist/js/treeshaking/utils/config.js +295 -117
- package/dist/js/treeshaking/utils/createFileWatcher.js +278 -118
- package/dist/js/treeshaking/utils/createServer.js +252 -67
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +182 -55
- package/dist/js/treeshaking/utils/language.js +6 -5
- package/dist/js/treeshaking/utils/printInstructions.js +151 -29
- package/dist/js/treeshaking/utils/restart.js +184 -42
- package/dist/js/treeshaking/utils/routes.js +151 -27
- package/dist/js/treeshaking/utils/types.js +1 -0
- package/dist/types/analyze/Builder.d.ts +8 -0
- package/dist/types/analyze/constants.d.ts +2 -0
- package/dist/types/analyze/index.d.ts +2 -0
- package/dist/types/analyze/templates.d.ts +10 -7
- package/dist/types/analyze/utils.d.ts +9 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -1
- package/dist/types/builder/index.d.ts +3 -3
- package/dist/types/builder/loaders/routerLoader.d.ts +3 -0
- package/dist/types/builder/loaders/serverModuleLoader.d.ts +3 -0
- package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +1 -7
- package/dist/types/defineConfig.d.ts +1 -0
- package/dist/types/index.d.ts +6 -1
- package/dist/types/initialize/index.d.ts +2 -0
- package/dist/types/types/config/dev.d.ts +2 -2
- package/dist/types/types/config/index.d.ts +1 -0
- package/dist/types/types/config/output.d.ts +0 -1
- package/dist/types/types/config/source.d.ts +1 -0
- package/dist/types/types/config/tools.d.ts +10 -1
- package/dist/types/types/hooks.d.ts +7 -1
- package/dist/types/types/legacyConfig/dev.d.ts +1 -0
- package/dist/types/types/legacyConfig/output.d.ts +1 -1
- package/dist/types/types/legacyConfig/source.d.ts +1 -0
- package/dist/types/types/legacyConfig/tools.d.ts +1 -0
- package/dist/types/utils/config.d.ts +1 -0
- package/dist/types/utils/createFileWatcher.d.ts +2 -1
- package/dist/types/utils/createServer.d.ts +1 -0
- package/dist/types/utils/restart.d.ts +1 -1
- package/lib/types.d.ts +1 -1
- package/package.json +26 -22
|
@@ -1,200 +1,273 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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 __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var stdin_exports = {};
|
|
25
|
+
__export(stdin_exports, {
|
|
26
|
+
default: () => analyze_default
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
+
var path = __toESM(require("path"));
|
|
30
|
+
var import_utils = require("@modern-js/utils");
|
|
31
|
+
var import_lodash = require("@modern-js/utils/lodash");
|
|
32
|
+
var import_builder = require("../builder");
|
|
33
|
+
var import_printInstructions = require("../utils/printInstructions");
|
|
34
|
+
var import_routes = require("../utils/routes");
|
|
35
|
+
var import_config = require("../utils/config");
|
|
36
|
+
var import_commands = require("../utils/commands");
|
|
37
|
+
var import_config2 = require("../config");
|
|
38
|
+
var import_utils2 = require("./utils");
|
|
39
|
+
var import_Builder = require("./Builder");
|
|
40
|
+
var __create2 = Object.create;
|
|
41
|
+
var __defProp2 = Object.defineProperty;
|
|
42
|
+
var __defProps = Object.defineProperties;
|
|
43
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
44
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
45
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
46
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
47
|
+
var __getProtoOf2 = Object.getPrototypeOf;
|
|
48
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
49
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
50
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
51
|
+
var __spreadValues = (a, b) => {
|
|
52
|
+
for (var prop in b || (b = {}))
|
|
53
|
+
if (__hasOwnProp2.call(b, prop))
|
|
54
|
+
__defNormalProp(a, prop, b[prop]);
|
|
55
|
+
if (__getOwnPropSymbols)
|
|
56
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
57
|
+
if (__propIsEnum.call(b, prop))
|
|
58
|
+
__defNormalProp(a, prop, b[prop]);
|
|
59
|
+
}
|
|
60
|
+
return a;
|
|
61
|
+
};
|
|
62
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
63
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
64
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
65
|
+
for (let key of __getOwnPropNames2(from))
|
|
66
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
67
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
68
|
+
}
|
|
69
|
+
return to;
|
|
70
|
+
};
|
|
71
|
+
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
|
|
72
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
|
|
73
|
+
mod
|
|
74
|
+
));
|
|
75
|
+
var __async = (__this, __arguments, generator) => {
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
var fulfilled = (value) => {
|
|
78
|
+
try {
|
|
79
|
+
step(generator.next(value));
|
|
80
|
+
} catch (e) {
|
|
81
|
+
reject(e);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var rejected = (value) => {
|
|
85
|
+
try {
|
|
86
|
+
step(generator.throw(value));
|
|
87
|
+
} catch (e) {
|
|
88
|
+
reject(e);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
92
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const debug = (0, import_utils.createDebugger)("plugin-analyze");
|
|
96
|
+
var analyze_default = () => ({
|
|
97
|
+
name: "@modern-js/plugin-analyze",
|
|
98
|
+
setup: (api) => {
|
|
26
99
|
let pagesDir = [];
|
|
27
100
|
let originEntrypoints = [];
|
|
28
101
|
return {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
routes:
|
|
102
|
+
prepare() {
|
|
103
|
+
return __async(this, null, function* () {
|
|
104
|
+
var _a2;
|
|
105
|
+
let appContext = api.useAppContext();
|
|
106
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
|
107
|
+
const hookRunners = api.useHookRunners();
|
|
108
|
+
try {
|
|
109
|
+
import_utils.fs.emptydirSync(appContext.internalDirectory);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
}
|
|
112
|
+
const apiOnly = yield (0, import_utils.isApiOnly)(
|
|
113
|
+
appContext.appDirectory,
|
|
114
|
+
(_a2 = resolvedConfig.source) == null ? void 0 : _a2.entriesDir
|
|
115
|
+
);
|
|
116
|
+
yield hookRunners.addRuntimeExports();
|
|
117
|
+
if (apiOnly) {
|
|
118
|
+
const { routes: routes2 } = yield hookRunners.modifyServerRoutes({
|
|
119
|
+
routes: []
|
|
120
|
+
});
|
|
121
|
+
debug(`server routes: %o`, routes2);
|
|
122
|
+
appContext = __spreadProps(__spreadValues({}, appContext), {
|
|
123
|
+
apiOnly,
|
|
124
|
+
serverRoutes: routes2
|
|
125
|
+
});
|
|
126
|
+
api.setAppContext(appContext);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const [
|
|
130
|
+
{ getBundleEntry },
|
|
131
|
+
{ getServerRoutes },
|
|
132
|
+
{ generateCode },
|
|
133
|
+
{ getHtmlTemplate }
|
|
134
|
+
] = yield Promise.all([
|
|
135
|
+
Promise.resolve().then(() => __toESM2(require("./getBundleEntry"))),
|
|
136
|
+
Promise.resolve().then(() => __toESM2(require("./getServerRoutes"))),
|
|
137
|
+
Promise.resolve().then(() => __toESM2(require("./generateCode"))),
|
|
138
|
+
Promise.resolve().then(() => __toESM2(require("./getHtmlTemplate")))
|
|
139
|
+
]);
|
|
140
|
+
const entrypoints = getBundleEntry(appContext, resolvedConfig);
|
|
141
|
+
const defaultChecked = entrypoints.map((point) => point.entryName);
|
|
142
|
+
debug(`entrypoints: %o`, entrypoints);
|
|
143
|
+
const initialRoutes = getServerRoutes(entrypoints, {
|
|
144
|
+
appContext,
|
|
145
|
+
config: resolvedConfig
|
|
146
|
+
});
|
|
147
|
+
const { routes } = yield hookRunners.modifyServerRoutes({
|
|
148
|
+
routes: initialRoutes
|
|
46
149
|
});
|
|
47
150
|
debug(`server routes: %o`, routes);
|
|
48
|
-
appContext =
|
|
49
|
-
|
|
151
|
+
appContext = __spreadProps(__spreadValues({}, appContext), {
|
|
152
|
+
entrypoints,
|
|
50
153
|
serverRoutes: routes
|
|
51
154
|
});
|
|
52
155
|
api.setAppContext(appContext);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
getServerRoutes
|
|
59
|
-
}, {
|
|
60
|
-
generateCode
|
|
61
|
-
}, {
|
|
62
|
-
getHtmlTemplate
|
|
63
|
-
}] = await Promise.all([Promise.resolve().then(() => _interopRequireWildcard(require("./getBundleEntry"))), Promise.resolve().then(() => _interopRequireWildcard(require("./getServerRoutes"))), Promise.resolve().then(() => _interopRequireWildcard(require("./generateCode"))), Promise.resolve().then(() => _interopRequireWildcard(require("./getHtmlTemplate")))]);
|
|
64
|
-
const entrypoints = getBundleEntry(appContext, resolvedConfig);
|
|
65
|
-
const defaultChecked = entrypoints.map(point => point.entryName);
|
|
66
|
-
debug(`entrypoints: %o`, entrypoints);
|
|
67
|
-
const initialRoutes = getServerRoutes(entrypoints, {
|
|
68
|
-
appContext,
|
|
69
|
-
config: resolvedConfig
|
|
70
|
-
});
|
|
71
|
-
const {
|
|
72
|
-
routes
|
|
73
|
-
} = await hookRunners.modifyServerRoutes({
|
|
74
|
-
routes: initialRoutes
|
|
75
|
-
});
|
|
76
|
-
debug(`server routes: %o`, routes);
|
|
77
|
-
appContext = _objectSpread(_objectSpread({}, appContext), {}, {
|
|
78
|
-
entrypoints,
|
|
79
|
-
serverRoutes: routes
|
|
80
|
-
});
|
|
81
|
-
api.setAppContext(appContext);
|
|
82
|
-
const nestedRouteEntries = entrypoints.map(point => point.nestedRoutesEntry).filter(Boolean);
|
|
83
|
-
pagesDir = entrypoints.map(point => point.entry).filter(Boolean).concat(nestedRouteEntries);
|
|
84
|
-
originEntrypoints = (0, _lodash.cloneDeep)(entrypoints);
|
|
85
|
-
await generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
86
|
-
const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
|
|
87
|
-
appContext,
|
|
88
|
-
config: resolvedConfig
|
|
89
|
-
});
|
|
90
|
-
debug(`html templates: %o`, htmlTemplates);
|
|
91
|
-
await hookRunners.addDefineTypes();
|
|
92
|
-
debug(`add Define Types`);
|
|
93
|
-
appContext = _objectSpread(_objectSpread({}, appContext), {}, {
|
|
94
|
-
entrypoints,
|
|
95
|
-
checkedEntries: defaultChecked,
|
|
96
|
-
apiOnly,
|
|
97
|
-
serverRoutes: routes,
|
|
98
|
-
htmlTemplates
|
|
99
|
-
});
|
|
100
|
-
api.setAppContext(appContext);
|
|
101
|
-
const command = (0, _commands.getCommand)();
|
|
102
|
-
const buildCommands = ['dev', 'build', 'inspect', 'deploy'];
|
|
103
|
-
if (buildCommands.includes(command)) {
|
|
104
|
-
const normalizedConfig = api.useResolvedConfigContext();
|
|
105
|
-
const builder = await (0, _builder.createBuilderForEdenX)({
|
|
106
|
-
normalizedConfig: normalizedConfig,
|
|
156
|
+
const nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
|
|
157
|
+
pagesDir = entrypoints.map((point) => point.entry).filter(Boolean).concat(nestedRouteEntries);
|
|
158
|
+
originEntrypoints = (0, import_lodash.cloneDeep)(entrypoints);
|
|
159
|
+
yield generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
160
|
+
const htmlTemplates = yield getHtmlTemplate(entrypoints, api, {
|
|
107
161
|
appContext,
|
|
108
|
-
|
|
109
|
-
async onBeforeBuild({
|
|
110
|
-
bundlerConfigs
|
|
111
|
-
}) {
|
|
112
|
-
const hookRunners = api.useHookRunners();
|
|
113
|
-
await (0, _routes.generateRoutes)(appContext);
|
|
114
|
-
await hookRunners.beforeBuild({
|
|
115
|
-
bundlerConfigs
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
async onAfterBuild({
|
|
119
|
-
stats
|
|
120
|
-
}) {
|
|
121
|
-
const hookRunners = api.useHookRunners();
|
|
122
|
-
await hookRunners.afterBuild({
|
|
123
|
-
stats
|
|
124
|
-
});
|
|
125
|
-
await (0, _config.emitResolvedConfig)(appContext.appDirectory, normalizedConfig);
|
|
126
|
-
},
|
|
127
|
-
async onDevCompileDone({
|
|
128
|
-
isFirstCompile
|
|
129
|
-
}) {
|
|
130
|
-
const hookRunners = api.useHookRunners();
|
|
131
|
-
if (process.stdout.isTTY || isFirstCompile) {
|
|
132
|
-
hookRunners.afterDev();
|
|
133
|
-
if (isFirstCompile) {
|
|
134
|
-
(0, _printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
async onBeforeCreateCompiler({
|
|
139
|
-
bundlerConfigs
|
|
140
|
-
}) {
|
|
141
|
-
const hookRunners = api.useHookRunners();
|
|
142
|
-
// run modernjs framework `beforeCreateCompiler` hook
|
|
143
|
-
await hookRunners.beforeCreateCompiler({
|
|
144
|
-
bundlerConfigs
|
|
145
|
-
});
|
|
146
|
-
},
|
|
147
|
-
async onAfterCreateCompiler({
|
|
148
|
-
compiler
|
|
149
|
-
}) {
|
|
150
|
-
const hookRunners = api.useHookRunners();
|
|
151
|
-
// run modernjs framework afterCreateCompiler hooks
|
|
152
|
-
await hookRunners.afterCreateCompiler({
|
|
153
|
-
compiler
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
162
|
+
config: resolvedConfig
|
|
157
163
|
});
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
debug(`html templates: %o`, htmlTemplates);
|
|
165
|
+
yield hookRunners.addDefineTypes();
|
|
166
|
+
debug(`add Define Types`);
|
|
167
|
+
appContext = __spreadProps(__spreadValues({}, appContext), {
|
|
168
|
+
entrypoints,
|
|
169
|
+
checkedEntries: defaultChecked,
|
|
170
|
+
apiOnly,
|
|
171
|
+
serverRoutes: routes,
|
|
172
|
+
htmlTemplates
|
|
160
173
|
});
|
|
161
174
|
api.setAppContext(appContext);
|
|
162
|
-
|
|
175
|
+
const command = (0, import_commands.getCommand)();
|
|
176
|
+
const buildCommands = ["dev", "build", "inspect", "deploy"];
|
|
177
|
+
if (buildCommands.includes(command)) {
|
|
178
|
+
let _b;
|
|
179
|
+
const normalizedConfig = api.useResolvedConfigContext();
|
|
180
|
+
const builder = yield (0, import_builder.createBuilderForModern)({
|
|
181
|
+
normalizedConfig,
|
|
182
|
+
appContext,
|
|
183
|
+
compatPluginConfig: {
|
|
184
|
+
onBeforeBuild(_0) {
|
|
185
|
+
return __async(this, arguments, function* ({ bundlerConfigs }) {
|
|
186
|
+
const hookRunners2 = api.useHookRunners();
|
|
187
|
+
yield (0, import_routes.generateRoutes)(appContext);
|
|
188
|
+
yield hookRunners2.beforeBuild({ bundlerConfigs });
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
onAfterBuild(_0) {
|
|
192
|
+
return __async(this, arguments, function* ({ stats }) {
|
|
193
|
+
const hookRunners2 = api.useHookRunners();
|
|
194
|
+
yield hookRunners2.afterBuild({ stats });
|
|
195
|
+
yield (0, import_config.emitResolvedConfig)(
|
|
196
|
+
appContext.appDirectory,
|
|
197
|
+
normalizedConfig
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
onDevCompileDone(_0) {
|
|
202
|
+
return __async(this, arguments, function* ({ isFirstCompile }) {
|
|
203
|
+
const hookRunners2 = api.useHookRunners();
|
|
204
|
+
if (process.stdout.isTTY || isFirstCompile) {
|
|
205
|
+
hookRunners2.afterDev();
|
|
206
|
+
if (isFirstCompile) {
|
|
207
|
+
(0, import_printInstructions.printInstructions)(
|
|
208
|
+
hookRunners2,
|
|
209
|
+
appContext,
|
|
210
|
+
normalizedConfig
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
onBeforeCreateCompiler(_0) {
|
|
217
|
+
return __async(this, arguments, function* ({ bundlerConfigs }) {
|
|
218
|
+
const hookRunners2 = api.useHookRunners();
|
|
219
|
+
yield hookRunners2.beforeCreateCompiler({
|
|
220
|
+
bundlerConfigs
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
},
|
|
224
|
+
onAfterCreateCompiler(_0) {
|
|
225
|
+
return __async(this, arguments, function* ({ compiler }) {
|
|
226
|
+
const hookRunners2 = api.useHookRunners();
|
|
227
|
+
yield hookRunners2.afterCreateCompiler({ compiler });
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
appContext = __spreadProps(__spreadValues({}, appContext), {
|
|
233
|
+
builder
|
|
234
|
+
});
|
|
235
|
+
api.setAppContext(appContext);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
163
238
|
},
|
|
164
239
|
watchFiles() {
|
|
165
240
|
return pagesDir;
|
|
166
241
|
},
|
|
167
|
-
resolvedConfig({
|
|
168
|
-
resolved
|
|
169
|
-
}) {
|
|
242
|
+
resolvedConfig({ resolved }) {
|
|
170
243
|
const appContext = api.useAppContext();
|
|
171
|
-
const config = (0,
|
|
244
|
+
const config = (0, import_config2.initialNormalizedConfig)(resolved, appContext);
|
|
172
245
|
return {
|
|
173
246
|
resolved: config
|
|
174
247
|
};
|
|
175
248
|
},
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
249
|
+
beforeRestart() {
|
|
250
|
+
return __async(this, null, function* () {
|
|
251
|
+
import_Builder.serverLoaderBuilder.stop();
|
|
252
|
+
import_Builder.loaderBuilder.stop();
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
fileChange(e) {
|
|
256
|
+
return __async(this, null, function* () {
|
|
257
|
+
const appContext = api.useAppContext();
|
|
258
|
+
const { appDirectory } = appContext;
|
|
259
|
+
const { filename, eventType } = e;
|
|
260
|
+
const isPageFile = (name) => pagesDir.some((pageDir) => name.includes(pageDir));
|
|
261
|
+
const absoluteFilePath = path.resolve(appDirectory, filename);
|
|
262
|
+
const isRouteComponent = isPageFile(absoluteFilePath) && (0, import_utils2.isRouteComponentFile)(absoluteFilePath);
|
|
263
|
+
if (isRouteComponent && (eventType === "add" || eventType === "unlink")) {
|
|
264
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
|
265
|
+
const { generateCode } = yield Promise.resolve().then(() => __toESM2(require("./generateCode")));
|
|
266
|
+
const entrypoints = (0, import_lodash.cloneDeep)(originEntrypoints);
|
|
267
|
+
generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
196
270
|
}
|
|
197
271
|
};
|
|
198
272
|
}
|
|
199
273
|
});
|
|
200
|
-
exports.default = _default;
|
|
@@ -1,33 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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 __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var stdin_exports = {};
|
|
25
|
+
__export(stdin_exports, {
|
|
26
|
+
isDefaultExportFunction: () => isDefaultExportFunction
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var t =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const isFunction = node => t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
|
|
15
|
-
const isDefaultExportFunction = file => {
|
|
16
|
-
if (!file || !_fs.default.existsSync(file)) {
|
|
28
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
+
var import_fs = __toESM(require("fs"));
|
|
30
|
+
var import_parser = require("@babel/parser");
|
|
31
|
+
var import_traverse = __toESM(require("@babel/traverse"));
|
|
32
|
+
var t = __toESM(require("@babel/types"));
|
|
33
|
+
const isFunction = (node) => t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
|
|
34
|
+
const isDefaultExportFunction = (file) => {
|
|
35
|
+
if (!file || !import_fs.default.existsSync(file)) {
|
|
17
36
|
return false;
|
|
18
37
|
}
|
|
19
|
-
const ast = (0,
|
|
20
|
-
sourceType:
|
|
21
|
-
plugins: [
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
const ast = (0, import_parser.parse)(import_fs.default.readFileSync(file, "utf8"), {
|
|
39
|
+
sourceType: "unambiguous",
|
|
40
|
+
plugins: [
|
|
41
|
+
"jsx",
|
|
42
|
+
"typescript",
|
|
43
|
+
"classProperties",
|
|
44
|
+
"dynamicImport",
|
|
45
|
+
"exportDefaultFrom",
|
|
46
|
+
"exportNamespaceFrom",
|
|
47
|
+
"decorators-legacy",
|
|
48
|
+
"functionBind",
|
|
49
|
+
"classPrivateMethods",
|
|
50
|
+
["pipelineOperator", { proposal: "minimal" }],
|
|
51
|
+
"optionalChaining",
|
|
52
|
+
"optionalCatchBinding",
|
|
53
|
+
"objectRestSpread",
|
|
54
|
+
"numericSeparator"
|
|
55
|
+
]
|
|
24
56
|
});
|
|
25
57
|
let isExportFunction = false;
|
|
26
|
-
(0,
|
|
27
|
-
ExportDefaultDeclaration: path => {
|
|
28
|
-
const {
|
|
29
|
-
declaration
|
|
30
|
-
} = path.node;
|
|
58
|
+
(0, import_traverse.default)(ast, {
|
|
59
|
+
ExportDefaultDeclaration: (path) => {
|
|
60
|
+
const { declaration } = path.node;
|
|
31
61
|
if (isFunction(declaration)) {
|
|
32
62
|
isExportFunction = true;
|
|
33
63
|
}
|
|
@@ -35,4 +65,3 @@ const isDefaultExportFunction = file => {
|
|
|
35
65
|
});
|
|
36
66
|
return isExportFunction;
|
|
37
67
|
};
|
|
38
|
-
exports.isDefaultExportFunction = isDefaultExportFunction;
|
|
@@ -1,20 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
makeLegalIdentifier: () => makeLegalIdentifier
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
|
|
12
|
-
const builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
|
|
13
|
-
const forbidList = new Set(`${reservedWords} ${builtins}`.split(' '));
|
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
23
|
+
const reservedWords = "break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public";
|
|
24
|
+
const builtins = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
|
|
25
|
+
const forbidList = new Set(`${reservedWords} ${builtins}`.split(" "));
|
|
14
26
|
function makeLegalIdentifier(str) {
|
|
15
|
-
const identifier = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g,
|
|
27
|
+
const identifier = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, "_");
|
|
16
28
|
if (/\d/.test(identifier[0]) || forbidList.has(identifier)) {
|
|
17
29
|
return `_${identifier}`;
|
|
18
30
|
}
|
|
19
|
-
return identifier ||
|
|
20
|
-
}
|
|
31
|
+
return identifier || "_";
|
|
32
|
+
}
|