@modern-js/app-tools 2.0.0-beta.3 → 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/dist/js/modern/analyze/constants.js +38 -18
- package/dist/js/modern/analyze/generateCode.js +261 -221
- 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 +106 -60
- package/dist/js/modern/analyze/templates.js +161 -80
- package/dist/js/modern/analyze/utils.js +87 -66
- package/dist/js/modern/builder/builderPlugins/compatModern.js +121 -109
- package/dist/js/modern/builder/index.js +122 -83
- package/dist/js/modern/builder/loaders/routerLoader.js +9 -12
- package/dist/js/modern/builder/loaders/serverModuleLoader.js +4 -1
- 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 +77 -27
- 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 -15
- package/dist/js/modern/config/default.js +103 -113
- 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 +9 -10
- 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 -39
- package/dist/js/node/analyze/generateCode.js +281 -239
- 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 +137 -75
- package/dist/js/node/analyze/templates.js +183 -89
- package/dist/js/node/analyze/utils.js +114 -81
- package/dist/js/node/builder/builderPlugins/compatModern.js +149 -122
- package/dist/js/node/builder/index.js +150 -92
- package/dist/js/node/builder/loaders/routerLoader.js +27 -18
- package/dist/js/node/builder/loaders/serverModuleLoader.js +22 -7
- 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 +99 -41
- 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 -26
- package/dist/js/node/config/default.js +119 -117
- 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 +26 -14
- 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 -61
- 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 -18
- package/dist/js/treeshaking/analyze/generateCode.js +599 -406
- 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 -147
- 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 +411 -200
- package/dist/js/treeshaking/analyze/templates.js +433 -236
- package/dist/js/treeshaking/analyze/utils.js +358 -153
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +281 -200
- package/dist/js/treeshaking/builder/index.js +371 -163
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +11 -12
- package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +3 -2
- 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 -131
- 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 -67
- package/dist/js/treeshaking/config/default.js +210 -198
- 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 -70
- 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/index.d.ts +2 -0
- package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -1
- package/dist/types/builder/index.d.ts +2 -2
- 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 +2 -0
- 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/createServer.d.ts +1 -0
- package/dist/types/utils/restart.d.ts +1 -1
- package/package.json +9 -8
|
@@ -1,20 +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
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
};
|
|
14
75
|
const index = ({
|
|
15
76
|
mountId,
|
|
16
77
|
imports,
|
|
17
|
-
renderFunction,
|
|
78
|
+
renderFunction: renderFunction2,
|
|
18
79
|
exportStatement
|
|
19
80
|
}) => `
|
|
20
81
|
const IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';
|
|
@@ -28,28 +89,25 @@ let AppWrapper = null;
|
|
|
28
89
|
let root = null;
|
|
29
90
|
|
|
30
91
|
function render() {
|
|
31
|
-
${
|
|
92
|
+
${renderFunction2}
|
|
32
93
|
}
|
|
33
94
|
|
|
34
95
|
AppWrapper = render();
|
|
35
96
|
|
|
36
97
|
${exportStatement};
|
|
37
98
|
`;
|
|
38
|
-
exports.index = index;
|
|
39
99
|
const renderFunction = ({
|
|
40
100
|
plugins,
|
|
41
101
|
customBootstrap,
|
|
42
|
-
fileSystemRoutes
|
|
102
|
+
fileSystemRoutes: fileSystemRoutes2
|
|
43
103
|
}) => `
|
|
44
104
|
AppWrapper = createApp({
|
|
45
105
|
plugins: [
|
|
46
|
-
${plugins.map(
|
|
47
|
-
name,
|
|
48
|
-
|
|
49
|
-
args
|
|
50
|
-
}) => `${name}({...${options}, ...App?.config?.${args || name}}),`).join('\n')}
|
|
106
|
+
${plugins.map(
|
|
107
|
+
({ name, options, args }) => `${name}({...${options}, ...App?.config?.${args || name}}),`
|
|
108
|
+
).join("\n")}
|
|
51
109
|
]
|
|
52
|
-
})(${
|
|
110
|
+
})(${fileSystemRoutes2 ? "" : `App`})
|
|
53
111
|
|
|
54
112
|
if (IS_BROWSER) {
|
|
55
113
|
${customBootstrap ? `customBootstrap(AppWrapper);` : `bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM);`}
|
|
@@ -57,20 +115,19 @@ const renderFunction = ({
|
|
|
57
115
|
|
|
58
116
|
return AppWrapper
|
|
59
117
|
`;
|
|
60
|
-
|
|
61
|
-
const html = partials => `
|
|
118
|
+
const html = (partials) => `
|
|
62
119
|
<!DOCTYPE html>
|
|
63
120
|
<html>
|
|
64
121
|
<head>
|
|
65
122
|
<%= meta %>
|
|
66
123
|
<title><%= title %></title>
|
|
67
124
|
|
|
68
|
-
${partials.top.join(
|
|
125
|
+
${partials.top.join("\n")}
|
|
69
126
|
|
|
70
127
|
<script>
|
|
71
128
|
window.__assetPrefix__ = '<%= assetPrefix %>';
|
|
72
|
-
|
|
73
|
-
${partials.head.join(
|
|
129
|
+
<\/script>
|
|
130
|
+
${partials.head.join("\n")}
|
|
74
131
|
|
|
75
132
|
<!--<?- chunksMap.css ?>-->
|
|
76
133
|
</head>
|
|
@@ -80,7 +137,7 @@ const html = partials => `
|
|
|
80
137
|
We're sorry but react app doesn't work properly without JavaScript enabled. Please enable it to continue.
|
|
81
138
|
</noscript>
|
|
82
139
|
<div id="<%= mountId %>"><!--<?- html ?>--></div>
|
|
83
|
-
${partials.body.join(
|
|
140
|
+
${partials.body.join("\n")}
|
|
84
141
|
<!--<?- chunksMap.js ?>-->
|
|
85
142
|
<!--<?- SSRDataScript ?>-->
|
|
86
143
|
<!--<?- bottomTemplate ?>-->
|
|
@@ -88,28 +145,32 @@ const html = partials => `
|
|
|
88
145
|
|
|
89
146
|
</html>
|
|
90
147
|
`;
|
|
91
|
-
exports.html = html;
|
|
92
148
|
const routesForServer = ({
|
|
93
149
|
routes,
|
|
94
150
|
internalDirectory,
|
|
95
151
|
entryName
|
|
96
152
|
}) => {
|
|
97
153
|
const loaders = [];
|
|
98
|
-
const loaderIndexFile =
|
|
99
|
-
|
|
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;
|
|
100
162
|
let children;
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
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);
|
|
104
165
|
}
|
|
105
166
|
let loader;
|
|
106
|
-
if (route.type ===
|
|
167
|
+
if (route.type === "nested") {
|
|
107
168
|
if (route.loader) {
|
|
108
169
|
loaders.push(route.loader);
|
|
109
170
|
loader = `loader_${loaders.length - 1}`;
|
|
110
171
|
}
|
|
111
172
|
}
|
|
112
|
-
const finalRoute =
|
|
173
|
+
const finalRoute = __spreadProps(__spreadValues({}, route), {
|
|
113
174
|
loader,
|
|
114
175
|
children
|
|
115
176
|
});
|
|
@@ -119,63 +180,81 @@ const routesForServer = ({
|
|
|
119
180
|
export const routes = [
|
|
120
181
|
`;
|
|
121
182
|
for (const route of routes) {
|
|
122
|
-
if (
|
|
183
|
+
if ("type" in route) {
|
|
123
184
|
const newRoute = traverseRouteTree(route);
|
|
124
|
-
routesCode += `${JSON.stringify(newRoute, null, 2).replace(
|
|
185
|
+
routesCode += `${JSON.stringify(newRoute, null, 2).replace(
|
|
186
|
+
/"(loader_[^"])"/g,
|
|
187
|
+
"$1"
|
|
188
|
+
)},`;
|
|
125
189
|
} else {
|
|
126
190
|
routesCode += `${JSON.stringify(route, null, 2)}`;
|
|
127
191
|
}
|
|
128
192
|
}
|
|
129
|
-
routesCode +=
|
|
130
|
-
|
|
193
|
+
routesCode += `
|
|
194
|
+
];`;
|
|
195
|
+
let importLoadersCode = "";
|
|
131
196
|
if (loaders.length > 0) {
|
|
132
197
|
importLoadersCode = `
|
|
133
|
-
import { ${loaders.map(
|
|
198
|
+
import { ${loaders.map(
|
|
199
|
+
(loader, index2) => `loader_${index2}`
|
|
200
|
+
)} } from "${(0, import_utils.slash)(loaderIndexFile)}"`;
|
|
134
201
|
}
|
|
135
202
|
return `
|
|
136
203
|
${importLoadersCode}
|
|
137
204
|
${routesCode}
|
|
138
205
|
`;
|
|
139
206
|
};
|
|
140
|
-
|
|
141
|
-
const fileSystemRoutes = async ({
|
|
207
|
+
const fileSystemRoutes = (_0) => __async(void 0, [_0], function* ({
|
|
142
208
|
routes,
|
|
143
209
|
ssrMode,
|
|
144
210
|
nestedRoutesEntry,
|
|
145
211
|
entryName,
|
|
146
212
|
internalDirectory
|
|
147
|
-
})
|
|
213
|
+
}) {
|
|
148
214
|
const loadings = [];
|
|
149
215
|
const errors = [];
|
|
150
216
|
const loaders = [];
|
|
151
217
|
const loadersMap = {};
|
|
152
|
-
const loadersIndexFile =
|
|
153
|
-
|
|
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
|
+
);
|
|
154
230
|
const importLazyCode = `
|
|
155
231
|
import { lazy } from "react";
|
|
156
232
|
import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"
|
|
157
233
|
`;
|
|
158
234
|
let rootLayoutCode = ``;
|
|
159
|
-
let dataLoaderPath =
|
|
160
|
-
let componentLoaderPath =
|
|
235
|
+
let dataLoaderPath = "";
|
|
236
|
+
let componentLoaderPath = "";
|
|
161
237
|
if (ssrMode) {
|
|
162
|
-
dataLoaderPath = require.resolve(
|
|
238
|
+
dataLoaderPath = require.resolve("@modern-js/plugin-data-loader/loader");
|
|
163
239
|
if (nestedRoutesEntry) {
|
|
164
240
|
dataLoaderPath = `${dataLoaderPath}?routesDir=${nestedRoutesEntry}&mapFile=${loadersMapFile}!`;
|
|
165
241
|
}
|
|
166
|
-
componentLoaderPath = `${
|
|
242
|
+
componentLoaderPath = `${import_path.default.join(
|
|
243
|
+
__dirname,
|
|
244
|
+
"../builder/loaders/routerLoader"
|
|
245
|
+
)}!`;
|
|
167
246
|
}
|
|
168
|
-
const traverseRouteTree = route => {
|
|
247
|
+
const traverseRouteTree = (route) => {
|
|
248
|
+
var _a;
|
|
169
249
|
let children;
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
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);
|
|
173
252
|
}
|
|
174
253
|
let loading;
|
|
175
254
|
let error;
|
|
176
255
|
let loader;
|
|
177
|
-
let component =
|
|
178
|
-
if (route.type ===
|
|
256
|
+
let component = "";
|
|
257
|
+
if (route.type === "nested") {
|
|
179
258
|
if (route.loading) {
|
|
180
259
|
loadings.push(route.loading);
|
|
181
260
|
loading = `loading_${loadings.length - 1}`;
|
|
@@ -194,17 +273,16 @@ const fileSystemRoutes = async ({
|
|
|
194
273
|
if (route.isRoot) {
|
|
195
274
|
rootLayoutCode = `import RootLayout from '${route._component}'`;
|
|
196
275
|
component = `RootLayout`;
|
|
197
|
-
} else if (ssrMode ===
|
|
276
|
+
} else if (ssrMode === "string") {
|
|
198
277
|
component = `loadable(() => import(/* webpackChunkName: "${route.id}" */ '${componentLoaderPath}${route._component}'))`;
|
|
199
278
|
} else {
|
|
200
|
-
// csr and streaming
|
|
201
279
|
component = `lazy(() => import(/* webpackChunkName: "${route.id}" */ '${componentLoaderPath}${route._component}'))`;
|
|
202
280
|
}
|
|
203
281
|
}
|
|
204
282
|
} else if (route._component) {
|
|
205
283
|
component = `loadable(() => import('${route._component}'))`;
|
|
206
284
|
}
|
|
207
|
-
const finalRoute =
|
|
285
|
+
const finalRoute = __spreadProps(__spreadValues({}, route), {
|
|
208
286
|
loading,
|
|
209
287
|
loader,
|
|
210
288
|
error,
|
|
@@ -219,45 +297,62 @@ const fileSystemRoutes = async ({
|
|
|
219
297
|
export const routes = [
|
|
220
298
|
`;
|
|
221
299
|
for (const route of routes) {
|
|
222
|
-
if (
|
|
300
|
+
if ("type" in route) {
|
|
223
301
|
const newRoute = traverseRouteTree(route);
|
|
224
|
-
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, '"')},`;
|
|
225
303
|
} else {
|
|
226
304
|
const component = `loadable(() => import('${route._component}'))`;
|
|
227
|
-
const finalRoute =
|
|
305
|
+
const finalRoute = __spreadProps(__spreadValues({}, route), {
|
|
228
306
|
component
|
|
229
307
|
});
|
|
230
|
-
routeComponentsCode += `${JSON.stringify(finalRoute, null, 2).replace(/"(loadable[^"]*)"/g,
|
|
308
|
+
routeComponentsCode += `${JSON.stringify(finalRoute, null, 2).replace(/"(loadable[^"]*)"/g, "$1").replace(/"(lazy[^"]*)"/g, "$1")},`;
|
|
231
309
|
}
|
|
232
310
|
}
|
|
233
|
-
routeComponentsCode +=
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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 = "";
|
|
241
322
|
if (loaders.length > 0) {
|
|
242
323
|
importLoadersCode = `
|
|
243
|
-
import { ${loaders.map(
|
|
324
|
+
import { ${loaders.map(
|
|
325
|
+
(loader, index2) => `loader_${index2}`
|
|
326
|
+
)} } from "${(0, import_utils.slash)(dataLoaderPath)}${(0, import_utils.slash)(loadersIndexFile)}"
|
|
244
327
|
`;
|
|
245
|
-
const loaderEntryCode = loaders.map((loader,
|
|
246
|
-
return `export * from './loader_${
|
|
247
|
-
}).join(
|
|
248
|
-
const loaderEntryFile =
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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)}'
|
|
257
351
|
`;
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
352
|
+
yield import_utils.fs.ensureFile(filename);
|
|
353
|
+
yield import_utils.fs.writeFile(filename, code);
|
|
354
|
+
}))
|
|
355
|
+
);
|
|
261
356
|
}
|
|
262
357
|
return `
|
|
263
358
|
${importLazyCode}
|
|
@@ -267,5 +362,4 @@ const fileSystemRoutes = async ({
|
|
|
267
362
|
${importLoadersCode}
|
|
268
363
|
${routeComponentsCode}
|
|
269
364
|
`;
|
|
270
|
-
};
|
|
271
|
-
exports.fileSystemRoutes = fileSystemRoutes;
|
|
365
|
+
});
|
|
@@ -1,25 +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
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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()) {
|
|
17
63
|
return [...previous, ...walkDirectory(filePath)];
|
|
18
64
|
} else {
|
|
19
65
|
return [...previous, filePath];
|
|
20
66
|
}
|
|
21
67
|
}, []);
|
|
22
|
-
exports.walkDirectory = walkDirectory;
|
|
23
68
|
const getDefaultImports = ({
|
|
24
69
|
entrypoint,
|
|
25
70
|
srcDirectory,
|
|
@@ -27,99 +72,87 @@ const getDefaultImports = ({
|
|
|
27
72
|
internalDirAlias,
|
|
28
73
|
internalDirectory
|
|
29
74
|
}) => {
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
}],
|
|
52
|
-
value: '@modern-js/runtime'
|
|
53
|
-
}, customBootstrap && {
|
|
54
|
-
specifiers: [{
|
|
55
|
-
local: 'customBootstrap'
|
|
56
|
-
}],
|
|
57
|
-
value: (0, _utils.normalizeToPosixPath)(customBootstrap.replace(srcDirectory, internalSrcAlias))
|
|
58
|
-
}].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);
|
|
59
96
|
if (fileSystemRoutes) {
|
|
60
97
|
const route = {
|
|
61
|
-
specifiers: [{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
+
)
|
|
65
105
|
};
|
|
66
106
|
if (fileSystemRoutes.globalApp) {
|
|
67
107
|
imports.push({
|
|
68
|
-
specifiers: [{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
108
|
+
specifiers: [{ local: "App" }],
|
|
109
|
+
value: (0, import_utils.normalizeToPosixPath)(
|
|
110
|
+
fileSystemRoutes.globalApp.replace(srcDirectory, internalSrcAlias)
|
|
111
|
+
)
|
|
72
112
|
});
|
|
73
113
|
} else {
|
|
74
|
-
route.initialize =
|
|
114
|
+
route.initialize = "const App = false;";
|
|
75
115
|
}
|
|
76
116
|
imports.push(route);
|
|
77
117
|
} else {
|
|
78
118
|
imports.push({
|
|
79
|
-
specifiers: [{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
119
|
+
specifiers: [{ local: "App" }],
|
|
120
|
+
value: (0, import_utils.normalizeToPosixPath)(
|
|
121
|
+
entry.replace(srcDirectory, internalSrcAlias)
|
|
122
|
+
)
|
|
83
123
|
});
|
|
84
124
|
}
|
|
85
125
|
return imports;
|
|
86
126
|
};
|
|
87
|
-
|
|
88
|
-
const isRouteComponentFile = filePath => {
|
|
127
|
+
const isRouteComponentFile = (filePath) => {
|
|
89
128
|
if (/\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/.test(filePath)) {
|
|
90
129
|
return false;
|
|
91
130
|
}
|
|
92
|
-
if ([
|
|
131
|
+
if ([".js", ".jsx", ".ts", ".tsx"].includes(import_path.default.extname(filePath))) {
|
|
93
132
|
return true;
|
|
94
133
|
}
|
|
95
134
|
return false;
|
|
96
135
|
};
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
exports.replaceWithAlias = replaceWithAlias;
|
|
100
|
-
const parseModule = async ({
|
|
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* ({
|
|
101
138
|
source,
|
|
102
139
|
filename
|
|
103
|
-
})
|
|
140
|
+
}) {
|
|
104
141
|
let content = source;
|
|
105
|
-
if (filename.endsWith(
|
|
106
|
-
const result =
|
|
107
|
-
loader:
|
|
108
|
-
format:
|
|
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"
|
|
109
146
|
});
|
|
110
147
|
content = result.code;
|
|
111
148
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const hasLoader = async filename => {
|
|
118
|
-
const source = await _utils.fs.readFile(filename);
|
|
119
|
-
const [, moduleExports] = await parseModule({
|
|
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({
|
|
120
154
|
source: source.toString(),
|
|
121
155
|
filename
|
|
122
156
|
});
|
|
123
|
-
return moduleExports.some(e => e.n ===
|
|
124
|
-
};
|
|
125
|
-
exports.hasLoader = hasLoader;
|
|
157
|
+
return moduleExports.some((e) => e.n === import_constants.LOADER_EXPORT_NAME);
|
|
158
|
+
});
|