@modern-js/app-tools 2.0.0-beta.2 → 2.0.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +251 -0
- package/bin/modern.js +10 -1
- package/dist/js/modern/analyze/constants.js +38 -16
- package/dist/js/modern/analyze/generateCode.js +271 -211
- package/dist/js/modern/analyze/getBundleEntry.js +31 -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 +193 -159
- 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 +190 -77
- package/dist/js/modern/analyze/utils.js +98 -51
- package/dist/js/modern/builder/builderPlugins/compatModern.js +124 -107
- package/dist/js/modern/builder/index.js +123 -86
- 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 +22 -20
- 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 +98 -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 +10 -3
- package/dist/js/modern/index.js +140 -89
- 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/constants.js +54 -35
- package/dist/js/node/analyze/generateCode.js +290 -228
- package/dist/js/node/analyze/getBundleEntry.js +55 -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 +240 -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 +211 -84
- package/dist/js/node/analyze/utils.js +123 -62
- package/dist/js/node/builder/builderPlugins/compatModern.js +152 -120
- package/dist/js/node/builder/index.js +151 -95
- 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 +45 -25
- 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 +116 -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 +44 -29
- package/dist/js/node/index.js +190 -130
- 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/constants.js +28 -16
- package/dist/js/treeshaking/analyze/generateCode.js +604 -355
- package/dist/js/treeshaking/analyze/getBundleEntry.js +52 -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 +558 -303
- 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 +281 -195
- package/dist/js/treeshaking/builder/index.js +371 -165
- 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 +41 -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 +332 -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 +26 -25
- package/dist/js/treeshaking/index.js +465 -257
- 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/constants.d.ts +2 -0
- package/dist/types/analyze/index.d.ts +2 -0
- package/dist/types/analyze/templates.d.ts +8 -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 +2 -2
- 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 +2 -0
- package/dist/types/initialize/index.d.ts +2 -0
- 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 +2 -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 +27 -23
|
@@ -1,16 +1,81 @@
|
|
|
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
|
+
fileSystemRoutes: () => fileSystemRoutes,
|
|
27
|
+
html: () => html,
|
|
28
|
+
index: () => index,
|
|
29
|
+
renderFunction: () => renderFunction,
|
|
30
|
+
routesForServer: () => routesForServer
|
|
5
31
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
32
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
33
|
+
var import_path = __toESM(require("path"));
|
|
34
|
+
var import_utils = require("@modern-js/utils");
|
|
35
|
+
var import_constants = require("./constants");
|
|
36
|
+
var __defProp2 = Object.defineProperty;
|
|
37
|
+
var __defProps = Object.defineProperties;
|
|
38
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
39
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
40
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
41
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
42
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
43
|
+
var __spreadValues = (a, b) => {
|
|
44
|
+
for (var prop in b || (b = {}))
|
|
45
|
+
if (__hasOwnProp2.call(b, prop))
|
|
46
|
+
__defNormalProp(a, prop, b[prop]);
|
|
47
|
+
if (__getOwnPropSymbols)
|
|
48
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
49
|
+
if (__propIsEnum.call(b, prop))
|
|
50
|
+
__defNormalProp(a, prop, b[prop]);
|
|
51
|
+
}
|
|
52
|
+
return a;
|
|
53
|
+
};
|
|
54
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
55
|
+
var __async = (__this, __arguments, generator) => {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
var fulfilled = (value) => {
|
|
58
|
+
try {
|
|
59
|
+
step(generator.next(value));
|
|
60
|
+
} catch (e) {
|
|
61
|
+
reject(e);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var rejected = (value) => {
|
|
65
|
+
try {
|
|
66
|
+
step(generator.throw(value));
|
|
67
|
+
} catch (e) {
|
|
68
|
+
reject(e);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
72
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
73
|
+
});
|
|
74
|
+
};
|
|
10
75
|
const index = ({
|
|
11
76
|
mountId,
|
|
12
77
|
imports,
|
|
13
|
-
renderFunction,
|
|
78
|
+
renderFunction: renderFunction2,
|
|
14
79
|
exportStatement
|
|
15
80
|
}) => `
|
|
16
81
|
const IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';
|
|
@@ -24,28 +89,25 @@ let AppWrapper = null;
|
|
|
24
89
|
let root = null;
|
|
25
90
|
|
|
26
91
|
function render() {
|
|
27
|
-
${
|
|
92
|
+
${renderFunction2}
|
|
28
93
|
}
|
|
29
94
|
|
|
30
95
|
AppWrapper = render();
|
|
31
96
|
|
|
32
97
|
${exportStatement};
|
|
33
98
|
`;
|
|
34
|
-
exports.index = index;
|
|
35
99
|
const renderFunction = ({
|
|
36
100
|
plugins,
|
|
37
101
|
customBootstrap,
|
|
38
|
-
fileSystemRoutes
|
|
102
|
+
fileSystemRoutes: fileSystemRoutes2
|
|
39
103
|
}) => `
|
|
40
104
|
AppWrapper = createApp({
|
|
41
105
|
plugins: [
|
|
42
|
-
${plugins.map(
|
|
43
|
-
name,
|
|
44
|
-
|
|
45
|
-
args
|
|
46
|
-
}) => `${name}({...${options}, ...App?.config?.${args || name}}),`).join('\n')}
|
|
106
|
+
${plugins.map(
|
|
107
|
+
({ name, options, args }) => `${name}({...${options}, ...App?.config?.${args || name}}),`
|
|
108
|
+
).join("\n")}
|
|
47
109
|
]
|
|
48
|
-
})(${
|
|
110
|
+
})(${fileSystemRoutes2 ? "" : `App`})
|
|
49
111
|
|
|
50
112
|
if (IS_BROWSER) {
|
|
51
113
|
${customBootstrap ? `customBootstrap(AppWrapper);` : `bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM);`}
|
|
@@ -53,20 +115,19 @@ const renderFunction = ({
|
|
|
53
115
|
|
|
54
116
|
return AppWrapper
|
|
55
117
|
`;
|
|
56
|
-
|
|
57
|
-
const html = partials => `
|
|
118
|
+
const html = (partials) => `
|
|
58
119
|
<!DOCTYPE html>
|
|
59
120
|
<html>
|
|
60
121
|
<head>
|
|
61
122
|
<%= meta %>
|
|
62
123
|
<title><%= title %></title>
|
|
63
124
|
|
|
64
|
-
${partials.top.join(
|
|
125
|
+
${partials.top.join("\n")}
|
|
65
126
|
|
|
66
127
|
<script>
|
|
67
128
|
window.__assetPrefix__ = '<%= assetPrefix %>';
|
|
68
|
-
|
|
69
|
-
${partials.head.join(
|
|
129
|
+
<\/script>
|
|
130
|
+
${partials.head.join("\n")}
|
|
70
131
|
|
|
71
132
|
<!--<?- chunksMap.css ?>-->
|
|
72
133
|
</head>
|
|
@@ -76,7 +137,7 @@ const html = partials => `
|
|
|
76
137
|
We're sorry but react app doesn't work properly without JavaScript enabled. Please enable it to continue.
|
|
77
138
|
</noscript>
|
|
78
139
|
<div id="<%= mountId %>"><!--<?- html ?>--></div>
|
|
79
|
-
${partials.body.join(
|
|
140
|
+
${partials.body.join("\n")}
|
|
80
141
|
<!--<?- chunksMap.js ?>-->
|
|
81
142
|
<!--<?- SSRDataScript ?>-->
|
|
82
143
|
<!--<?- bottomTemplate ?>-->
|
|
@@ -84,30 +145,32 @@ const html = partials => `
|
|
|
84
145
|
|
|
85
146
|
</html>
|
|
86
147
|
`;
|
|
87
|
-
exports.html = html;
|
|
88
148
|
const routesForServer = ({
|
|
89
149
|
routes,
|
|
90
|
-
|
|
150
|
+
internalDirectory,
|
|
151
|
+
entryName
|
|
91
152
|
}) => {
|
|
92
|
-
const {
|
|
93
|
-
name,
|
|
94
|
-
basename
|
|
95
|
-
} = alias;
|
|
96
153
|
const loaders = [];
|
|
97
|
-
const
|
|
154
|
+
const loaderIndexFile = import_path.default.join(
|
|
155
|
+
internalDirectory,
|
|
156
|
+
entryName,
|
|
157
|
+
import_constants.TEMP_LOADERS_DIR,
|
|
158
|
+
"index.js"
|
|
159
|
+
);
|
|
160
|
+
const traverseRouteTree = (route) => {
|
|
161
|
+
var _a;
|
|
98
162
|
let children;
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
children = route === null || route === void 0 ? void 0 : (_route$children = route.children) === null || _route$children === void 0 ? void 0 : _route$children.map(traverseRouteTree);
|
|
163
|
+
if ("children" in route && route.children) {
|
|
164
|
+
children = (_a = route == null ? void 0 : route.children) == null ? void 0 : _a.map(traverseRouteTree);
|
|
102
165
|
}
|
|
103
166
|
let loader;
|
|
104
|
-
if (route.type ===
|
|
167
|
+
if (route.type === "nested") {
|
|
105
168
|
if (route.loader) {
|
|
106
169
|
loaders.push(route.loader);
|
|
107
170
|
loader = `loader_${loaders.length - 1}`;
|
|
108
171
|
}
|
|
109
172
|
}
|
|
110
|
-
const finalRoute =
|
|
173
|
+
const finalRoute = __spreadProps(__spreadValues({}, route), {
|
|
111
174
|
loader,
|
|
112
175
|
children
|
|
113
176
|
});
|
|
@@ -117,58 +180,81 @@ const routesForServer = ({
|
|
|
117
180
|
export const routes = [
|
|
118
181
|
`;
|
|
119
182
|
for (const route of routes) {
|
|
120
|
-
if (
|
|
183
|
+
if ("type" in route) {
|
|
121
184
|
const newRoute = traverseRouteTree(route);
|
|
122
|
-
routesCode += `${JSON.stringify(newRoute, null, 2).replace(
|
|
185
|
+
routesCode += `${JSON.stringify(newRoute, null, 2).replace(
|
|
186
|
+
/"(loader_[^"])"/g,
|
|
187
|
+
"$1"
|
|
188
|
+
)},`;
|
|
123
189
|
} else {
|
|
124
190
|
routesCode += `${JSON.stringify(route, null, 2)}`;
|
|
125
191
|
}
|
|
126
192
|
}
|
|
127
|
-
routesCode +=
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
193
|
+
routesCode += `
|
|
194
|
+
];`;
|
|
195
|
+
let importLoadersCode = "";
|
|
196
|
+
if (loaders.length > 0) {
|
|
197
|
+
importLoadersCode = `
|
|
198
|
+
import { ${loaders.map(
|
|
199
|
+
(loader, index2) => `loader_${index2}`
|
|
200
|
+
)} } from "${(0, import_utils.slash)(loaderIndexFile)}"`;
|
|
201
|
+
}
|
|
132
202
|
return `
|
|
133
203
|
${importLoadersCode}
|
|
134
204
|
${routesCode}
|
|
135
205
|
`;
|
|
136
206
|
};
|
|
137
|
-
|
|
138
|
-
const fileSystemRoutes = ({
|
|
207
|
+
const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
139
208
|
routes,
|
|
140
209
|
ssrMode,
|
|
141
210
|
nestedRoutesEntry,
|
|
142
|
-
entryName
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
211
|
+
entryName,
|
|
212
|
+
internalDirectory
|
|
213
|
+
}) {
|
|
214
|
+
const loadings = [];
|
|
215
|
+
const errors = [];
|
|
216
|
+
const loaders = [];
|
|
217
|
+
const loadersMap = {};
|
|
218
|
+
const loadersIndexFile = import_path.default.join(
|
|
219
|
+
"@_modern_js_internal",
|
|
220
|
+
entryName,
|
|
221
|
+
import_constants.TEMP_LOADERS_DIR,
|
|
222
|
+
"index.js"
|
|
223
|
+
);
|
|
224
|
+
const loadersMapFile = import_path.default.join(
|
|
225
|
+
internalDirectory,
|
|
226
|
+
entryName,
|
|
227
|
+
import_constants.TEMP_LOADERS_DIR,
|
|
228
|
+
"map.json"
|
|
229
|
+
);
|
|
147
230
|
const importLazyCode = `
|
|
148
231
|
import { lazy } from "react";
|
|
149
232
|
import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"
|
|
150
233
|
`;
|
|
151
|
-
let
|
|
234
|
+
let rootLayoutCode = ``;
|
|
235
|
+
let dataLoaderPath = "";
|
|
236
|
+
let componentLoaderPath = "";
|
|
152
237
|
if (ssrMode) {
|
|
153
|
-
dataLoaderPath = require.resolve(
|
|
238
|
+
dataLoaderPath = require.resolve("@modern-js/plugin-data-loader/loader");
|
|
154
239
|
if (nestedRoutesEntry) {
|
|
155
|
-
dataLoaderPath = `${dataLoaderPath}?routesDir=${nestedRoutesEntry}&
|
|
240
|
+
dataLoaderPath = `${dataLoaderPath}?routesDir=${nestedRoutesEntry}&mapFile=${loadersMapFile}!`;
|
|
156
241
|
}
|
|
242
|
+
componentLoaderPath = `${import_path.default.join(
|
|
243
|
+
__dirname,
|
|
244
|
+
"../builder/loaders/routerLoader"
|
|
245
|
+
)}!`;
|
|
157
246
|
}
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
const loaders = [];
|
|
161
|
-
const traverseRouteTree = route => {
|
|
247
|
+
const traverseRouteTree = (route) => {
|
|
248
|
+
var _a;
|
|
162
249
|
let children;
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
children = route === null || route === void 0 ? void 0 : (_route$children2 = route.children) === null || _route$children2 === void 0 ? void 0 : _route$children2.map(traverseRouteTree);
|
|
250
|
+
if ("children" in route && route.children) {
|
|
251
|
+
children = (_a = route == null ? void 0 : route.children) == null ? void 0 : _a.map(traverseRouteTree);
|
|
166
252
|
}
|
|
167
253
|
let loading;
|
|
168
254
|
let error;
|
|
169
255
|
let loader;
|
|
170
|
-
let component =
|
|
171
|
-
if (route.type ===
|
|
256
|
+
let component = "";
|
|
257
|
+
if (route.type === "nested") {
|
|
172
258
|
if (route.loading) {
|
|
173
259
|
loadings.push(route.loading);
|
|
174
260
|
loading = `loading_${loadings.length - 1}`;
|
|
@@ -179,19 +265,24 @@ const fileSystemRoutes = ({
|
|
|
179
265
|
}
|
|
180
266
|
if (route.loader) {
|
|
181
267
|
loaders.push(route.loader);
|
|
182
|
-
|
|
268
|
+
const loaderId = loaders.length - 1;
|
|
269
|
+
loader = `loader_${loaderId}`;
|
|
270
|
+
loadersMap[loader] = route.id;
|
|
183
271
|
}
|
|
184
272
|
if (route._component) {
|
|
185
|
-
if (
|
|
186
|
-
|
|
273
|
+
if (route.isRoot) {
|
|
274
|
+
rootLayoutCode = `import RootLayout from '${route._component}'`;
|
|
275
|
+
component = `RootLayout`;
|
|
276
|
+
} else if (ssrMode === "string") {
|
|
277
|
+
component = `loadable(() => import(/* webpackChunkName: "${route.id}" */ '${componentLoaderPath}${route._component}'))`;
|
|
187
278
|
} else {
|
|
188
|
-
component = `
|
|
279
|
+
component = `lazy(() => import(/* webpackChunkName: "${route.id}" */ '${componentLoaderPath}${route._component}'))`;
|
|
189
280
|
}
|
|
190
281
|
}
|
|
191
282
|
} else if (route._component) {
|
|
192
283
|
component = `loadable(() => import('${route._component}'))`;
|
|
193
284
|
}
|
|
194
|
-
const finalRoute =
|
|
285
|
+
const finalRoute = __spreadProps(__spreadValues({}, route), {
|
|
195
286
|
loading,
|
|
196
287
|
loader,
|
|
197
288
|
error,
|
|
@@ -206,33 +297,69 @@ const fileSystemRoutes = ({
|
|
|
206
297
|
export const routes = [
|
|
207
298
|
`;
|
|
208
299
|
for (const route of routes) {
|
|
209
|
-
if (
|
|
300
|
+
if ("type" in route) {
|
|
210
301
|
const newRoute = traverseRouteTree(route);
|
|
211
|
-
routeComponentsCode += `${JSON.stringify(newRoute, null, 2).replace(/"(loadable.*\))"/g,
|
|
302
|
+
routeComponentsCode += `${JSON.stringify(newRoute, null, 2).replace(/"(loadable.*\))"/g, "$1").replace(/"(loadableLazy.*\))"/g, "$1").replace(/"(lazy.*\))"/g, "$1").replace(/"(loading_[^"])"/g, "$1").replace(/"(loader_[^"])"/g, "$1").replace(/"(RootLayout)"/g, "$1").replace(/"(error_[^"])"/g, "$1").replace(/\\"/g, '"')},`;
|
|
212
303
|
} else {
|
|
213
304
|
const component = `loadable(() => import('${route._component}'))`;
|
|
214
|
-
const finalRoute =
|
|
305
|
+
const finalRoute = __spreadProps(__spreadValues({}, route), {
|
|
215
306
|
component
|
|
216
307
|
});
|
|
217
|
-
routeComponentsCode += `${JSON.stringify(finalRoute, null, 2).replace(/"(loadable[^"]*)"/g,
|
|
308
|
+
routeComponentsCode += `${JSON.stringify(finalRoute, null, 2).replace(/"(loadable[^"]*)"/g, "$1").replace(/"(lazy[^"]*)"/g, "$1")},`;
|
|
218
309
|
}
|
|
219
310
|
}
|
|
220
|
-
routeComponentsCode +=
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}).join(
|
|
311
|
+
routeComponentsCode += `
|
|
312
|
+
];`;
|
|
313
|
+
const importLoadingCode = loadings.map((loading, index2) => {
|
|
314
|
+
return `import loading_${index2} from '${loading}';
|
|
315
|
+
`;
|
|
316
|
+
}).join("");
|
|
317
|
+
const importErrorComponentsCode = errors.map((error, index2) => {
|
|
318
|
+
return `import error_${index2} from '${error}';
|
|
319
|
+
`;
|
|
320
|
+
}).join("");
|
|
321
|
+
let importLoadersCode = "";
|
|
322
|
+
if (loaders.length > 0) {
|
|
323
|
+
importLoadersCode = `
|
|
324
|
+
import { ${loaders.map(
|
|
325
|
+
(loader, index2) => `loader_${index2}`
|
|
326
|
+
)} } from "${(0, import_utils.slash)(dataLoaderPath)}${(0, import_utils.slash)(loadersIndexFile)}"
|
|
327
|
+
`;
|
|
328
|
+
const loaderEntryCode = loaders.map((loader, index2) => {
|
|
329
|
+
return `export * from './loader_${index2}.js';`;
|
|
330
|
+
}).join("\n");
|
|
331
|
+
const loaderEntryFile = import_path.default.join(
|
|
332
|
+
internalDirectory,
|
|
333
|
+
entryName,
|
|
334
|
+
import_constants.TEMP_LOADERS_DIR,
|
|
335
|
+
"entry.js"
|
|
336
|
+
);
|
|
337
|
+
yield import_utils.fs.ensureFile(loaderEntryFile);
|
|
338
|
+
yield import_utils.fs.writeFile(loaderEntryFile, loaderEntryCode);
|
|
339
|
+
yield import_utils.fs.writeJSON(loadersMapFile, loadersMap);
|
|
340
|
+
yield Promise.all(
|
|
341
|
+
loaders.map((loader, index2) => __async(void 0, null, function* () {
|
|
342
|
+
const name = `loader_${index2}`;
|
|
343
|
+
const filename = import_path.default.join(
|
|
344
|
+
internalDirectory,
|
|
345
|
+
entryName,
|
|
346
|
+
import_constants.TEMP_LOADERS_DIR,
|
|
347
|
+
`${name}.js`
|
|
348
|
+
);
|
|
349
|
+
const code = `
|
|
350
|
+
export { loader as ${name} } from '${(0, import_utils.slash)(loader)}'
|
|
351
|
+
`;
|
|
352
|
+
yield import_utils.fs.ensureFile(filename);
|
|
353
|
+
yield import_utils.fs.writeFile(filename, code);
|
|
354
|
+
}))
|
|
355
|
+
);
|
|
356
|
+
}
|
|
230
357
|
return `
|
|
231
358
|
${importLazyCode}
|
|
359
|
+
${rootLayoutCode}
|
|
232
360
|
${importLoadingCode}
|
|
233
361
|
${importErrorComponentsCode}
|
|
234
|
-
${
|
|
362
|
+
${importLoadersCode}
|
|
235
363
|
${routeComponentsCode}
|
|
236
364
|
`;
|
|
237
|
-
};
|
|
238
|
-
exports.fileSystemRoutes = fileSystemRoutes;
|
|
365
|
+
});
|
|
@@ -1,23 +1,70 @@
|
|
|
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
|
+
getDefaultImports: () => getDefaultImports,
|
|
27
|
+
hasLoader: () => hasLoader,
|
|
28
|
+
isRouteComponentFile: () => isRouteComponentFile,
|
|
29
|
+
parseModule: () => parseModule,
|
|
30
|
+
replaceWithAlias: () => replaceWithAlias,
|
|
31
|
+
walkDirectory: () => walkDirectory
|
|
5
32
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
34
|
+
var import_fs = __toESM(require("fs"));
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_utils = require("@modern-js/utils");
|
|
37
|
+
var import_esbuild = require("esbuild");
|
|
38
|
+
var import_es_module_lexer = require("es-module-lexer");
|
|
39
|
+
var import_constants = require("./constants");
|
|
40
|
+
var __async = (__this, __arguments, generator) => {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
var fulfilled = (value) => {
|
|
43
|
+
try {
|
|
44
|
+
step(generator.next(value));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
reject(e);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var rejected = (value) => {
|
|
50
|
+
try {
|
|
51
|
+
step(generator.throw(value));
|
|
52
|
+
} catch (e) {
|
|
53
|
+
reject(e);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
57
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
const walkDirectory = (dir) => import_fs.default.readdirSync(dir).reduce((previous, filename) => {
|
|
61
|
+
const filePath = import_path.default.join(dir, filename);
|
|
62
|
+
if (import_fs.default.statSync(filePath).isDirectory()) {
|
|
15
63
|
return [...previous, ...walkDirectory(filePath)];
|
|
16
64
|
} else {
|
|
17
65
|
return [...previous, filePath];
|
|
18
66
|
}
|
|
19
67
|
}, []);
|
|
20
|
-
exports.walkDirectory = walkDirectory;
|
|
21
68
|
const getDefaultImports = ({
|
|
22
69
|
entrypoint,
|
|
23
70
|
srcDirectory,
|
|
@@ -25,73 +72,87 @@ const getDefaultImports = ({
|
|
|
25
72
|
internalDirAlias,
|
|
26
73
|
internalDirectory
|
|
27
74
|
}) => {
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
}],
|
|
50
|
-
value: '@modern-js/runtime'
|
|
51
|
-
}, customBootstrap && {
|
|
52
|
-
specifiers: [{
|
|
53
|
-
local: 'customBootstrap'
|
|
54
|
-
}],
|
|
55
|
-
value: (0, _utils.normalizeToPosixPath)(customBootstrap.replace(srcDirectory, internalSrcAlias))
|
|
56
|
-
}].filter(Boolean);
|
|
75
|
+
const { entryName, fileSystemRoutes, customBootstrap, entry } = entrypoint;
|
|
76
|
+
const imports = [
|
|
77
|
+
{
|
|
78
|
+
specifiers: [{ local: "React" }],
|
|
79
|
+
value: "react"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
specifiers: [{ local: "ReactDOM" }],
|
|
83
|
+
value: (0, import_utils.isReact18)(import_path.default.join(internalDirectory, "../../")) ? "react-dom/client" : "react-dom"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
specifiers: [{ imported: "createApp" }, { imported: "bootstrap" }],
|
|
87
|
+
value: "@modern-js/runtime"
|
|
88
|
+
},
|
|
89
|
+
customBootstrap && {
|
|
90
|
+
specifiers: [{ local: "customBootstrap" }],
|
|
91
|
+
value: (0, import_utils.normalizeToPosixPath)(
|
|
92
|
+
customBootstrap.replace(srcDirectory, internalSrcAlias)
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
].filter(Boolean);
|
|
57
96
|
if (fileSystemRoutes) {
|
|
58
97
|
const route = {
|
|
59
|
-
specifiers: [{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
98
|
+
specifiers: [{ imported: "routes" }],
|
|
99
|
+
value: (0, import_utils.normalizeToPosixPath)(
|
|
100
|
+
`${internalDirAlias}/${entryName}/${import_constants.FILE_SYSTEM_ROUTES_FILE_NAME.replace(
|
|
101
|
+
".js",
|
|
102
|
+
""
|
|
103
|
+
)}`
|
|
104
|
+
)
|
|
63
105
|
};
|
|
64
106
|
if (fileSystemRoutes.globalApp) {
|
|
65
107
|
imports.push({
|
|
66
|
-
specifiers: [{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
108
|
+
specifiers: [{ local: "App" }],
|
|
109
|
+
value: (0, import_utils.normalizeToPosixPath)(
|
|
110
|
+
fileSystemRoutes.globalApp.replace(srcDirectory, internalSrcAlias)
|
|
111
|
+
)
|
|
70
112
|
});
|
|
71
113
|
} else {
|
|
72
|
-
route.initialize =
|
|
114
|
+
route.initialize = "const App = false;";
|
|
73
115
|
}
|
|
74
116
|
imports.push(route);
|
|
75
117
|
} else {
|
|
76
118
|
imports.push({
|
|
77
|
-
specifiers: [{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
119
|
+
specifiers: [{ local: "App" }],
|
|
120
|
+
value: (0, import_utils.normalizeToPosixPath)(
|
|
121
|
+
entry.replace(srcDirectory, internalSrcAlias)
|
|
122
|
+
)
|
|
81
123
|
});
|
|
82
124
|
}
|
|
83
125
|
return imports;
|
|
84
126
|
};
|
|
85
|
-
|
|
86
|
-
const isRouteComponentFile = filePath => {
|
|
127
|
+
const isRouteComponentFile = (filePath) => {
|
|
87
128
|
if (/\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/.test(filePath)) {
|
|
88
129
|
return false;
|
|
89
130
|
}
|
|
90
|
-
if ([
|
|
131
|
+
if ([".js", ".jsx", ".ts", ".tsx"].includes(import_path.default.extname(filePath))) {
|
|
91
132
|
return true;
|
|
92
133
|
}
|
|
93
134
|
return false;
|
|
94
135
|
};
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
136
|
+
const replaceWithAlias = (base, filePath, alias) => (0, import_utils.normalizeToPosixPath)(import_path.default.join(alias, import_path.default.relative(base, filePath)));
|
|
137
|
+
const parseModule = (_0) => __async(void 0, [_0], function* ({
|
|
138
|
+
source,
|
|
139
|
+
filename
|
|
140
|
+
}) {
|
|
141
|
+
let content = source;
|
|
142
|
+
if (filename.endsWith(".tsx") || filename.endsWith(".jsx")) {
|
|
143
|
+
const result = yield (0, import_esbuild.transform)(content, {
|
|
144
|
+
loader: import_path.default.extname(filename).slice(1),
|
|
145
|
+
format: "esm"
|
|
146
|
+
});
|
|
147
|
+
content = result.code;
|
|
148
|
+
}
|
|
149
|
+
return yield (0, import_es_module_lexer.parse)(content);
|
|
150
|
+
});
|
|
151
|
+
const hasLoader = (filename) => __async(void 0, null, function* () {
|
|
152
|
+
const source = yield import_utils.fs.readFile(filename);
|
|
153
|
+
const [, moduleExports] = yield parseModule({
|
|
154
|
+
source: source.toString(),
|
|
155
|
+
filename
|
|
156
|
+
});
|
|
157
|
+
return moduleExports.some((e) => e.n === import_constants.LOADER_EXPORT_NAME);
|
|
158
|
+
});
|