@modern-js/app-tools 2.35.1 → 2.36.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/cjs/analyze/constants.js +68 -75
- package/dist/cjs/analyze/generateCode.js +74 -57
- package/dist/cjs/analyze/getBundleEntry.js +53 -27
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +63 -37
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +63 -37
- package/dist/cjs/analyze/getClientRoutes/index.js +27 -17
- package/dist/cjs/analyze/getClientRoutes/utils.js +47 -30
- package/dist/cjs/analyze/getFileSystemEntry.js +58 -32
- package/dist/cjs/analyze/getHtmlTemplate.js +45 -20
- package/dist/cjs/analyze/getServerRoutes.js +55 -29
- package/dist/cjs/analyze/index.js +81 -61
- package/dist/cjs/analyze/isDefaultExportFunction.js +42 -17
- package/dist/cjs/analyze/makeLegalIdentifier.js +24 -7
- package/dist/cjs/analyze/nestedRoutes.js +111 -65
- package/dist/cjs/analyze/templates.js +135 -53
- package/dist/cjs/analyze/utils.js +101 -67
- package/dist/cjs/builder/builder-rspack/adapterCopy.js +60 -30
- package/dist/cjs/builder/builder-rspack/index.js +29 -12
- package/dist/cjs/builder/builder-webpack/adapterModern.js +26 -11
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +30 -20
- package/dist/cjs/builder/builder-webpack/index.js +40 -14
- package/dist/cjs/builder/generator/createBuilderOptions.js +24 -7
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +26 -9
- package/dist/cjs/builder/generator/getBuilderTargets.js +27 -10
- package/dist/cjs/builder/generator/index.js +44 -18
- package/dist/cjs/builder/index.js +39 -13
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +36 -7
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +36 -19
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +47 -21
- package/dist/cjs/builder/shared/builderPlugins/index.js +24 -6
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -10
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +29 -12
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +42 -25
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +24 -6
- package/dist/cjs/builder/shared/createCopyInfo.js +38 -12
- package/dist/cjs/builder/shared/index.js +24 -6
- package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +21 -8
- package/dist/cjs/builder/shared/types.js +15 -3
- package/dist/cjs/commands/build.js +33 -16
- package/dist/cjs/commands/deploy.js +24 -7
- package/dist/cjs/commands/dev.js +40 -23
- package/dist/cjs/commands/index.js +24 -6
- package/dist/cjs/commands/inspect.js +26 -9
- package/dist/cjs/commands/serve.js +48 -22
- package/dist/cjs/config/default.js +33 -23
- package/dist/cjs/config/index.js +24 -6
- package/dist/cjs/config/initialize/index.js +27 -10
- package/dist/cjs/config/initialize/inits.js +40 -37
- package/dist/cjs/config/legacy/createHtmlConfig.js +24 -7
- package/dist/cjs/config/legacy/createOutputConfig.js +24 -7
- package/dist/cjs/config/legacy/createSourceConfig.js +24 -7
- package/dist/cjs/config/legacy/createToolsConfig.js +24 -7
- package/dist/cjs/config/legacy/index.js +34 -23
- package/dist/cjs/defineConfig.js +25 -15
- package/dist/cjs/exports/server.js +25 -8
- package/dist/cjs/hooks.js +50 -33
- package/dist/cjs/index.js +95 -80
- package/dist/cjs/initialize/index.js +30 -17
- package/dist/cjs/locale/en.js +24 -7
- package/dist/cjs/locale/index.js +31 -21
- package/dist/cjs/locale/zh.js +24 -7
- package/dist/cjs/schema/Schema.js +28 -11
- package/dist/cjs/schema/index.js +40 -21
- package/dist/cjs/schema/legacy.js +30 -17
- package/dist/cjs/types/config/deploy.js +15 -3
- package/dist/cjs/types/config/dev.js +15 -3
- package/dist/cjs/types/config/experiments.js +15 -3
- package/dist/cjs/types/config/html.js +15 -3
- package/dist/cjs/types/config/index.js +20 -4
- package/dist/cjs/types/config/output.js +15 -3
- package/dist/cjs/types/config/performance.js +15 -3
- package/dist/cjs/types/config/security.js +15 -3
- package/dist/cjs/types/config/source.js +15 -3
- package/dist/cjs/types/config/testing.js +15 -3
- package/dist/cjs/types/config/tools.js +15 -3
- package/dist/cjs/types/hooks.js +15 -3
- package/dist/cjs/types/index.js +24 -6
- package/dist/cjs/types/legacyConfig/deploy.js +15 -3
- package/dist/cjs/types/legacyConfig/dev.js +15 -3
- package/dist/cjs/types/legacyConfig/index.js +15 -3
- package/dist/cjs/types/legacyConfig/output.js +15 -3
- package/dist/cjs/types/legacyConfig/source.js +15 -3
- package/dist/cjs/types/legacyConfig/testing.js +15 -3
- package/dist/cjs/types/legacyConfig/tools.js +15 -3
- package/dist/cjs/types/utils.js +15 -3
- package/dist/cjs/utils/config.js +50 -33
- package/dist/cjs/utils/createServer.js +43 -26
- package/dist/cjs/utils/env.js +26 -9
- package/dist/cjs/utils/generateWatchFiles.js +41 -22
- package/dist/cjs/utils/getSelectedEntries.js +30 -13
- package/dist/cjs/utils/getServerInternalPlugins.js +24 -7
- package/dist/cjs/utils/printInstructions.js +27 -10
- package/dist/cjs/utils/restart.js +30 -13
- package/dist/cjs/utils/routes.js +37 -11
- package/dist/cjs/utils/types.js +15 -3
- package/dist/esm/analyze/constants.js +48 -22
- package/dist/esm/analyze/generateCode.js +38 -33
- package/dist/esm/analyze/getBundleEntry.js +4 -1
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +12 -9
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +12 -9
- package/dist/esm/analyze/getClientRoutes/index.js +6 -2
- package/dist/esm/analyze/getClientRoutes/utils.js +9 -4
- package/dist/esm/analyze/getFileSystemEntry.js +10 -7
- package/dist/esm/analyze/getHtmlTemplate.js +7 -4
- package/dist/esm/analyze/getServerRoutes.js +8 -5
- package/dist/esm/analyze/index.js +31 -30
- package/dist/esm/analyze/isDefaultExportFunction.js +4 -1
- package/dist/esm/analyze/makeLegalIdentifier.js +4 -1
- package/dist/esm/analyze/nestedRoutes.js +93 -30
- package/dist/esm/analyze/templates.js +121 -30
- package/dist/esm/analyze/utils.js +103 -18
- package/dist/esm/builder/builder-rspack/adapterCopy.js +16 -9
- package/dist/esm/builder/builder-rspack/index.js +4 -1
- package/dist/esm/builder/builder-webpack/adapterModern.js +4 -3
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +8 -4
- package/dist/esm/builder/builder-webpack/index.js +4 -1
- package/dist/esm/builder/generator/createBuilderOptions.js +5 -2
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +4 -1
- package/dist/esm/builder/generator/getBuilderTargets.js +4 -1
- package/dist/esm/builder/generator/index.js +5 -2
- package/dist/esm/builder/index.js +4 -1
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +6 -1
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +11 -8
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +10 -7
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +4 -1
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +4 -1
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +7 -4
- package/dist/esm/builder/shared/createCopyInfo.js +7 -4
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +4 -1
- package/dist/esm/builder/shared/types.js +0 -1
- package/dist/esm/commands/build.js +6 -3
- package/dist/esm/commands/deploy.js +4 -1
- package/dist/esm/commands/dev.js +12 -9
- package/dist/esm/commands/inspect.js +4 -1
- package/dist/esm/commands/serve.js +7 -4
- package/dist/esm/config/default.js +12 -8
- package/dist/esm/config/initialize/index.js +4 -1
- package/dist/esm/config/initialize/inits.js +8 -19
- package/dist/esm/config/legacy/createHtmlConfig.js +17 -14
- package/dist/esm/config/legacy/createOutputConfig.js +19 -16
- package/dist/esm/config/legacy/createSourceConfig.js +14 -11
- package/dist/esm/config/legacy/createToolsConfig.js +18 -15
- package/dist/esm/config/legacy/index.js +21 -16
- package/dist/esm/defineConfig.js +6 -2
- package/dist/esm/exports/server.js +4 -1
- package/dist/esm/hooks.js +4 -1
- package/dist/esm/index.js +19 -11
- package/dist/esm/initialize/index.js +9 -6
- package/dist/esm/locale/en.js +4 -1
- package/dist/esm/locale/index.js +4 -1
- package/dist/esm/locale/zh.js +4 -1
- package/dist/esm/schema/Schema.js +6 -3
- package/dist/esm/schema/index.js +5 -2
- package/dist/esm/schema/legacy.js +4 -1
- package/dist/esm/types/config/deploy.js +0 -1
- package/dist/esm/types/config/dev.js +0 -1
- package/dist/esm/types/config/experiments.js +0 -1
- package/dist/esm/types/config/html.js +0 -1
- package/dist/esm/types/config/output.js +0 -1
- package/dist/esm/types/config/performance.js +0 -1
- package/dist/esm/types/config/security.js +0 -1
- package/dist/esm/types/config/source.js +0 -1
- package/dist/esm/types/config/testing.js +0 -1
- package/dist/esm/types/config/tools.js +0 -1
- package/dist/esm/types/hooks.js +0 -1
- package/dist/esm/types/legacyConfig/deploy.js +0 -1
- package/dist/esm/types/legacyConfig/dev.js +0 -1
- package/dist/esm/types/legacyConfig/index.js +0 -1
- package/dist/esm/types/legacyConfig/output.js +0 -1
- package/dist/esm/types/legacyConfig/source.js +0 -1
- package/dist/esm/types/legacyConfig/testing.js +0 -1
- package/dist/esm/types/legacyConfig/tools.js +0 -1
- package/dist/esm/types/utils.js +0 -1
- package/dist/esm/utils/config.js +12 -6
- package/dist/esm/utils/createServer.js +12 -5
- package/dist/esm/utils/env.js +4 -1
- package/dist/esm/utils/generateWatchFiles.js +6 -2
- package/dist/esm/utils/getSelectedEntries.js +4 -1
- package/dist/esm/utils/getServerInternalPlugins.js +5 -2
- package/dist/esm/utils/printInstructions.js +4 -1
- package/dist/esm/utils/restart.js +4 -1
- package/dist/esm/utils/routes.js +3 -1
- package/dist/esm/utils/types.js +0 -1
- package/dist/esm-node/analyze/constants.js +48 -22
- package/dist/esm-node/analyze/generateCode.js +8 -3
- package/dist/esm-node/analyze/getBundleEntry.js +4 -1
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +4 -1
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +4 -1
- package/dist/esm-node/analyze/getClientRoutes/index.js +6 -2
- package/dist/esm-node/analyze/getClientRoutes/utils.js +9 -4
- package/dist/esm-node/analyze/getFileSystemEntry.js +4 -1
- package/dist/esm-node/analyze/getHtmlTemplate.js +4 -1
- package/dist/esm-node/analyze/getServerRoutes.js +4 -1
- package/dist/esm-node/analyze/index.js +9 -8
- package/dist/esm-node/analyze/isDefaultExportFunction.js +4 -1
- package/dist/esm-node/analyze/makeLegalIdentifier.js +4 -1
- package/dist/esm-node/analyze/nestedRoutes.js +42 -9
- package/dist/esm-node/analyze/templates.js +93 -18
- package/dist/esm-node/analyze/utils.js +48 -16
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +18 -11
- package/dist/esm-node/builder/builder-rspack/index.js +4 -1
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +4 -3
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +6 -2
- package/dist/esm-node/builder/builder-webpack/index.js +4 -1
- package/dist/esm-node/builder/generator/createBuilderOptions.js +4 -1
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +4 -1
- package/dist/esm-node/builder/generator/getBuilderTargets.js +4 -1
- package/dist/esm-node/builder/generator/index.js +4 -1
- package/dist/esm-node/builder/index.js +4 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +6 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +4 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +4 -1
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +4 -1
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +4 -1
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +4 -1
- package/dist/esm-node/builder/shared/createCopyInfo.js +4 -1
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +4 -1
- package/dist/esm-node/builder/shared/types.js +0 -1
- package/dist/esm-node/commands/build.js +4 -1
- package/dist/esm-node/commands/deploy.js +4 -1
- package/dist/esm-node/commands/dev.js +4 -1
- package/dist/esm-node/commands/inspect.js +4 -1
- package/dist/esm-node/commands/serve.js +4 -1
- package/dist/esm-node/config/default.js +6 -2
- package/dist/esm-node/config/initialize/index.js +4 -1
- package/dist/esm-node/config/initialize/inits.js +8 -20
- package/dist/esm-node/config/legacy/createHtmlConfig.js +4 -1
- package/dist/esm-node/config/legacy/createOutputConfig.js +4 -1
- package/dist/esm-node/config/legacy/createSourceConfig.js +4 -1
- package/dist/esm-node/config/legacy/createToolsConfig.js +4 -1
- package/dist/esm-node/config/legacy/index.js +7 -2
- package/dist/esm-node/defineConfig.js +6 -2
- package/dist/esm-node/exports/server.js +4 -1
- package/dist/esm-node/hooks.js +4 -1
- package/dist/esm-node/index.js +14 -6
- package/dist/esm-node/initialize/index.js +4 -1
- package/dist/esm-node/locale/en.js +4 -1
- package/dist/esm-node/locale/index.js +4 -1
- package/dist/esm-node/locale/zh.js +4 -1
- package/dist/esm-node/schema/Schema.js +4 -1
- package/dist/esm-node/schema/index.js +5 -2
- package/dist/esm-node/schema/legacy.js +4 -1
- package/dist/esm-node/types/config/deploy.js +0 -1
- package/dist/esm-node/types/config/dev.js +0 -1
- package/dist/esm-node/types/config/experiments.js +0 -1
- package/dist/esm-node/types/config/html.js +0 -1
- package/dist/esm-node/types/config/output.js +0 -1
- package/dist/esm-node/types/config/performance.js +0 -1
- package/dist/esm-node/types/config/security.js +0 -1
- package/dist/esm-node/types/config/source.js +0 -1
- package/dist/esm-node/types/config/testing.js +0 -1
- package/dist/esm-node/types/config/tools.js +0 -1
- package/dist/esm-node/types/hooks.js +0 -1
- package/dist/esm-node/types/legacyConfig/deploy.js +0 -1
- package/dist/esm-node/types/legacyConfig/dev.js +0 -1
- package/dist/esm-node/types/legacyConfig/index.js +0 -1
- package/dist/esm-node/types/legacyConfig/output.js +0 -1
- package/dist/esm-node/types/legacyConfig/source.js +0 -1
- package/dist/esm-node/types/legacyConfig/testing.js +0 -1
- package/dist/esm-node/types/legacyConfig/tools.js +0 -1
- package/dist/esm-node/types/utils.js +0 -1
- package/dist/esm-node/utils/config.js +10 -4
- package/dist/esm-node/utils/createServer.js +12 -5
- package/dist/esm-node/utils/env.js +4 -1
- package/dist/esm-node/utils/generateWatchFiles.js +6 -2
- package/dist/esm-node/utils/getSelectedEntries.js +4 -1
- package/dist/esm-node/utils/getServerInternalPlugins.js +4 -1
- package/dist/esm-node/utils/printInstructions.js +4 -1
- package/dist/esm-node/utils/restart.js +4 -1
- package/dist/esm-node/utils/routes.js +3 -1
- package/dist/esm-node/utils/types.js +0 -1
- package/dist/types/analyze/constants.d.ts +1 -0
- package/dist/types/analyze/utils.d.ts +2 -1
- package/dist/types/types/config/index.d.ts +3 -2
- package/package.json +24 -24
@@ -1,19 +1,40 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
9
17
|
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var getHtmlTemplate_exports = {};
|
30
|
+
__export(getHtmlTemplate_exports, {
|
31
|
+
getHtmlTemplate: () => getHtmlTemplate
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
const _templates = /* @__PURE__ */ _interop_require_wildcard._(require("./templates"));
|
33
|
+
module.exports = __toCommonJS(getHtmlTemplate_exports);
|
34
|
+
var import_path = __toESM(require("path"));
|
35
|
+
var import_utils = require("@modern-js/utils");
|
36
|
+
var import_constants = require("./constants");
|
37
|
+
var templates = __toESM(require("./templates"));
|
17
38
|
var PartialPosition;
|
18
39
|
(function(PartialPosition2) {
|
19
40
|
PartialPosition2["TOP"] = "top";
|
@@ -23,12 +44,12 @@ var PartialPosition;
|
|
23
44
|
PartialPosition2["INDEX"] = "index";
|
24
45
|
})(PartialPosition || (PartialPosition = {}));
|
25
46
|
const findPartials = (dir, entryName, position) => {
|
26
|
-
if (
|
27
|
-
const base = (0,
|
28
|
-
const file = entryName ? (0,
|
47
|
+
if (import_utils.fs.existsSync(dir)) {
|
48
|
+
const base = (0, import_utils.findExists)(import_constants.HTML_PARTIALS_EXTENSIONS.map((ext) => import_path.default.resolve(dir, `${position}${ext}`)));
|
49
|
+
const file = entryName ? (0, import_utils.findExists)(import_constants.HTML_PARTIALS_EXTENSIONS.map((ext) => import_path.default.resolve(dir, entryName, `${position}${ext}`))) || base : base;
|
29
50
|
return file ? {
|
30
51
|
file,
|
31
|
-
content:
|
52
|
+
content: import_utils.fs.readFileSync(file, "utf8")
|
32
53
|
} : null;
|
33
54
|
}
|
34
55
|
return null;
|
@@ -36,7 +57,7 @@ const findPartials = (dir, entryName, position) => {
|
|
36
57
|
const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
37
58
|
const { appDirectory, internalDirectory } = appContext;
|
38
59
|
const { source: { configDir } } = config;
|
39
|
-
const htmlDir =
|
60
|
+
const htmlDir = import_path.default.resolve(appDirectory, configDir || "", import_constants.HTML_PARTIALS_FOLDER);
|
40
61
|
const htmlTemplates = {};
|
41
62
|
const partialsByEntrypoint = {};
|
42
63
|
for (const entrypoint of entrypoints) {
|
@@ -65,8 +86,8 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
65
86
|
body: []
|
66
87
|
})
|
67
88
|
});
|
68
|
-
const templatePath =
|
69
|
-
|
89
|
+
const templatePath = import_path.default.resolve(internalDirectory, entryName, "index.html");
|
90
|
+
import_utils.fs.outputFileSync(templatePath, templates.html(partials), "utf8");
|
70
91
|
htmlTemplates[entryName] = templatePath;
|
71
92
|
partialsByEntrypoint[entryName] = partials;
|
72
93
|
const bottomTemplate = findPartials(htmlDir, name, PartialPosition.BOTTOM);
|
@@ -81,3 +102,7 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
81
102
|
});
|
82
103
|
return htmlTemplates;
|
83
104
|
};
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
106
|
+
0 && (module.exports = {
|
107
|
+
getHtmlTemplate
|
108
|
+
});
|
@@ -1,18 +1,40 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
9
17
|
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var getServerRoutes_exports = {};
|
30
|
+
__export(getServerRoutes_exports, {
|
31
|
+
getServerRoutes: () => getServerRoutes
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
33
|
+
module.exports = __toCommonJS(getServerRoutes_exports);
|
34
|
+
var import_path = __toESM(require("path"));
|
35
|
+
var import_fs = __toESM(require("fs"));
|
36
|
+
var import_utils = require("@modern-js/utils");
|
37
|
+
var import_utils2 = require("./utils");
|
16
38
|
const applyBaseUrl = (baseUrl, routes) => {
|
17
39
|
if (baseUrl) {
|
18
40
|
if (Array.isArray(baseUrl)) {
|
@@ -22,10 +44,10 @@ const applyBaseUrl = (baseUrl, routes) => {
|
|
22
44
|
], []);
|
23
45
|
} else {
|
24
46
|
return routes.map((route) => {
|
25
|
-
const urlPath = (0,
|
47
|
+
const urlPath = (0, import_utils.urlJoin)(baseUrl, route.urlPath);
|
26
48
|
return {
|
27
49
|
...route,
|
28
|
-
urlPath: urlPath === "/" ? urlPath : (0,
|
50
|
+
urlPath: urlPath === "/" ? urlPath : (0, import_utils.removeTailSlash)(urlPath)
|
29
51
|
};
|
30
52
|
});
|
31
53
|
}
|
@@ -35,12 +57,12 @@ const applyBaseUrl = (baseUrl, routes) => {
|
|
35
57
|
const applyRouteOptions = (original, routeOptions) => {
|
36
58
|
const { route, disableSpa } = routeOptions;
|
37
59
|
original.isSPA = !disableSpa;
|
38
|
-
!original.isSPA && (original.entryPath =
|
60
|
+
!original.isSPA && (original.entryPath = import_path.default.dirname(original.entryPath));
|
39
61
|
let routes;
|
40
62
|
if (route) {
|
41
63
|
if (Array.isArray(route)) {
|
42
64
|
routes = route.map((url) => {
|
43
|
-
if ((0,
|
65
|
+
if ((0, import_utils.isPlainObject)(url)) {
|
44
66
|
const { path: urlPath, ...other } = url;
|
45
67
|
return {
|
46
68
|
...original,
|
@@ -54,7 +76,7 @@ const applyRouteOptions = (original, routeOptions) => {
|
|
54
76
|
};
|
55
77
|
}
|
56
78
|
});
|
57
|
-
} else if ((0,
|
79
|
+
} else if ((0, import_utils.isPlainObject)(route)) {
|
58
80
|
const { path: urlPath, ...other } = route;
|
59
81
|
routes = [
|
60
82
|
{
|
@@ -84,8 +106,8 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
84
106
|
const { packageName } = appContext;
|
85
107
|
const workerSSR = deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr;
|
86
108
|
let htmlRoutes = entrypoints.reduce((previous, { entryName }) => {
|
87
|
-
const isMainEntry = entryName === (mainEntryName ||
|
88
|
-
const entryOptions = (0,
|
109
|
+
const isMainEntry = entryName === (mainEntryName || import_utils.MAIN_ENTRY_NAME);
|
110
|
+
const entryOptions = (0, import_utils.getEntryOptions)(entryName, isMainEntry, ssr, ssrByEntries, packageName);
|
89
111
|
const isSSR = Boolean(entryOptions);
|
90
112
|
const isWorker = Boolean(workerSSR);
|
91
113
|
const isStream = typeof entryOptions === "object" && (entryOptions.mode === "stream" || Boolean(entryOptions.preload));
|
@@ -93,16 +115,16 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
93
115
|
let route = {
|
94
116
|
urlPath: `/${isMainEntry ? "" : entryName}`,
|
95
117
|
entryName,
|
96
|
-
entryPath: (0,
|
118
|
+
entryPath: (0, import_utils.removeLeadingSlash)(import_path.default.posix.normalize(`${htmlPath}/${entryName}${disableHtmlFolder ? ".html" : "/index.html"}`)),
|
97
119
|
isSPA: true,
|
98
120
|
isStream,
|
99
121
|
isSSR,
|
100
122
|
responseHeaders: resHeaders,
|
101
|
-
worker: isWorker ? `${
|
102
|
-
bundle: isSSR ? `${
|
123
|
+
worker: isWorker ? `${import_utils.SERVER_WORKER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0,
|
124
|
+
bundle: isSSR ? `${import_utils.SERVER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0
|
103
125
|
};
|
104
126
|
if (routes === null || routes === void 0 ? void 0 : routes.hasOwnProperty(entryName)) {
|
105
|
-
const routeOptions = (0,
|
127
|
+
const routeOptions = (0, import_utils.isPlainObject)(routes[entryName]) ? routes[entryName] : {
|
106
128
|
route: routes[entryName]
|
107
129
|
};
|
108
130
|
route = applyRouteOptions(route, routeOptions);
|
@@ -121,14 +143,14 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
121
143
|
const collectStaticRoutes = (appContext, config) => {
|
122
144
|
const { appDirectory } = appContext;
|
123
145
|
const { source: { configDir }, server: { publicRoutes = {} } } = config;
|
124
|
-
const publicFolder =
|
125
|
-
return
|
126
|
-
const urlPath = `${(0,
|
146
|
+
const publicFolder = import_path.default.resolve(appDirectory, configDir || "", "public");
|
147
|
+
return import_fs.default.existsSync(publicFolder) ? (0, import_utils2.walkDirectory)(publicFolder).map((filePath) => {
|
148
|
+
const urlPath = `${(0, import_utils.urlJoin)(toPosix(filePath).slice(toPosix(publicFolder).length))}`;
|
127
149
|
return {
|
128
|
-
urlPath: publicRoutes[(0,
|
150
|
+
urlPath: publicRoutes[(0, import_utils.removeLeadingSlash)(urlPath)] || urlPath,
|
129
151
|
isSPA: true,
|
130
152
|
isSSR: false,
|
131
|
-
entryPath: toPosix(
|
153
|
+
entryPath: toPosix(import_path.default.relative(import_path.default.resolve(appDirectory, configDir || ""), filePath))
|
132
154
|
};
|
133
155
|
}) : [];
|
134
156
|
};
|
@@ -136,4 +158,8 @@ const getServerRoutes = (entrypoints, { appContext, config }) => [
|
|
136
158
|
...collectHtmlRoutes(entrypoints, appContext, config),
|
137
159
|
...collectStaticRoutes(appContext, config)
|
138
160
|
];
|
139
|
-
const toPosix = (pathStr) => pathStr.split(
|
161
|
+
const toPosix = (pathStr) => pathStr.split(import_path.default.sep).join(import_path.default.posix.sep);
|
162
|
+
// Annotate the CommonJS export names for ESM import in node:
|
163
|
+
0 && (module.exports = {
|
164
|
+
getServerRoutes
|
165
|
+
});
|
@@ -1,28 +1,50 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
9
17
|
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var analyze_exports = {};
|
30
|
+
__export(analyze_exports, {
|
31
|
+
default: () => analyze_default
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const debug = (0,
|
25
|
-
|
33
|
+
module.exports = __toCommonJS(analyze_exports);
|
34
|
+
var path = __toESM(require("path"));
|
35
|
+
var import_utils = require("@modern-js/utils");
|
36
|
+
var import_lodash = require("@modern-js/utils/lodash");
|
37
|
+
var import_printInstructions = require("../utils/printInstructions");
|
38
|
+
var import_routes = require("../utils/routes");
|
39
|
+
var import_config = require("../utils/config");
|
40
|
+
var import_getSelectedEntries = require("../utils/getSelectedEntries");
|
41
|
+
var import_config2 = require("../config");
|
42
|
+
var import_builder = require("../builder");
|
43
|
+
var import_utils2 = require("./utils");
|
44
|
+
var import_constants = require("./constants");
|
45
|
+
var import_generateCode = require("./generateCode");
|
46
|
+
const debug = (0, import_utils.createDebugger)("plugin-analyze");
|
47
|
+
var analyze_default = ({ bundler }) => ({
|
26
48
|
name: "@modern-js/plugin-analyze",
|
27
49
|
setup: (api) => {
|
28
50
|
let pagesDir = [];
|
@@ -35,12 +57,12 @@ const _default = ({ bundler }) => ({
|
|
35
57
|
const resolvedConfig = api.useResolvedConfigContext();
|
36
58
|
const hookRunners = api.useHookRunners();
|
37
59
|
try {
|
38
|
-
if ((0,
|
39
|
-
|
60
|
+
if ((0, import_utils2.checkIsBuildCommands)()) {
|
61
|
+
import_utils.fs.emptydirSync(appContext.internalDirectory);
|
40
62
|
}
|
41
63
|
} catch {
|
42
64
|
}
|
43
|
-
const apiOnly = await (0,
|
65
|
+
const apiOnly = await (0, import_utils.isApiOnly)(appContext.appDirectory, (_resolvedConfig_source = resolvedConfig.source) === null || _resolvedConfig_source === void 0 ? void 0 : _resolvedConfig_source.entriesDir, appContext.apiDirectory);
|
44
66
|
await hookRunners.addRuntimeExports();
|
45
67
|
if (apiOnly) {
|
46
68
|
const { routes: routes2 } = await hookRunners.modifyServerRoutes({
|
@@ -56,10 +78,10 @@ const _default = ({ bundler }) => ({
|
|
56
78
|
return;
|
57
79
|
}
|
58
80
|
const [{ getBundleEntry }, { getServerRoutes }, { generateCode }, { getHtmlTemplate }] = await Promise.all([
|
59
|
-
Promise.resolve().then(() =>
|
60
|
-
Promise.resolve().then(() =>
|
61
|
-
Promise.resolve().then(() =>
|
62
|
-
Promise.resolve().then(() =>
|
81
|
+
Promise.resolve().then(() => __toESM(require("./getBundleEntry"))),
|
82
|
+
Promise.resolve().then(() => __toESM(require("./getServerRoutes"))),
|
83
|
+
Promise.resolve().then(() => __toESM(require("./generateCode"))),
|
84
|
+
Promise.resolve().then(() => __toESM(require("./getHtmlTemplate")))
|
63
85
|
]);
|
64
86
|
const entrypoints = getBundleEntry(appContext, resolvedConfig);
|
65
87
|
debug(`entrypoints: %o`, entrypoints);
|
@@ -78,8 +100,8 @@ const _default = ({ bundler }) => ({
|
|
78
100
|
};
|
79
101
|
api.setAppContext(appContext);
|
80
102
|
nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
|
81
|
-
pagesDir = entrypoints.map((point) => point.entry).filter((entry) => entry && !
|
82
|
-
originEntrypoints = (0,
|
103
|
+
pagesDir = entrypoints.map((point) => point.entry).filter((entry) => entry && !path.extname(entry)).concat(nestedRouteEntries);
|
104
|
+
originEntrypoints = (0, import_lodash.cloneDeep)(entrypoints);
|
83
105
|
const { importsStatemets } = await generateCode(appContext, resolvedConfig, entrypoints, api);
|
84
106
|
const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
|
85
107
|
appContext,
|
@@ -89,9 +111,9 @@ const _default = ({ bundler }) => ({
|
|
89
111
|
await hookRunners.addDefineTypes();
|
90
112
|
debug(`add Define Types`);
|
91
113
|
let checkedEntries = entrypoints.map((point) => point.entryName);
|
92
|
-
if ((0,
|
93
|
-
const { entry } = (0,
|
94
|
-
checkedEntries = await (0,
|
114
|
+
if ((0, import_utils.isDevCommand)()) {
|
115
|
+
const { entry } = (0, import_utils.minimist)((0, import_utils.getArgv)());
|
116
|
+
checkedEntries = await (0, import_getSelectedEntries.getSelectedEntries)(typeof entry === "string" ? entry.split(",") : entry, entrypoints);
|
95
117
|
}
|
96
118
|
appContext = {
|
97
119
|
...api.useAppContext(),
|
@@ -102,16 +124,16 @@ const _default = ({ bundler }) => ({
|
|
102
124
|
htmlTemplates
|
103
125
|
};
|
104
126
|
api.setAppContext(appContext);
|
105
|
-
if ((0,
|
127
|
+
if ((0, import_utils2.checkIsBuildCommands)()) {
|
106
128
|
const normalizedConfig = api.useResolvedConfigContext();
|
107
|
-
const createBuilderForModern = await (0,
|
129
|
+
const createBuilderForModern = await (0, import_builder.createBuilderGenerator)(bundler);
|
108
130
|
const builder = await createBuilderForModern({
|
109
131
|
normalizedConfig,
|
110
132
|
appContext
|
111
133
|
});
|
112
134
|
builder.onBeforeBuild(async ({ bundlerConfigs }) => {
|
113
135
|
const hookRunners2 = api.useHookRunners();
|
114
|
-
await (0,
|
136
|
+
await (0, import_routes.generateRoutes)(appContext);
|
115
137
|
await hookRunners2.beforeBuild({
|
116
138
|
bundlerConfigs
|
117
139
|
});
|
@@ -121,22 +143,20 @@ const _default = ({ bundler }) => ({
|
|
121
143
|
await hookRunners2.afterBuild({
|
122
144
|
stats
|
123
145
|
});
|
124
|
-
await (0,
|
146
|
+
await (0, import_config.emitResolvedConfig)(appContext.appDirectory, normalizedConfig);
|
125
147
|
});
|
126
148
|
builder.onDevCompileDone(async ({ isFirstCompile }) => {
|
127
149
|
const hookRunners2 = api.useHookRunners();
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
(0, _printInstructions.printInstructions)(hookRunners2, appContext, normalizedConfig);
|
134
|
-
}
|
150
|
+
hookRunners2.afterDev({
|
151
|
+
isFirstCompile
|
152
|
+
});
|
153
|
+
if (isFirstCompile) {
|
154
|
+
(0, import_printInstructions.printInstructions)(hookRunners2, appContext, normalizedConfig);
|
135
155
|
}
|
136
156
|
});
|
137
157
|
builder.onBeforeCreateCompiler(async ({ bundlerConfigs }) => {
|
138
158
|
const hookRunners2 = api.useHookRunners();
|
139
|
-
await (0,
|
159
|
+
await (0, import_generateCode.generateIndexCode)({
|
140
160
|
appContext,
|
141
161
|
config: resolvedConfig,
|
142
162
|
entrypoints,
|
@@ -170,7 +190,7 @@ const _default = ({ bundler }) => ({
|
|
170
190
|
},
|
171
191
|
resolvedConfig({ resolved }) {
|
172
192
|
const appContext = api.useAppContext();
|
173
|
-
const config = (0,
|
193
|
+
const config = (0, import_config2.initialNormalizedConfig)(resolved, appContext, bundler);
|
174
194
|
return {
|
175
195
|
resolved: config
|
176
196
|
};
|
@@ -181,40 +201,40 @@ const _default = ({ bundler }) => ({
|
|
181
201
|
const { srcDirectory, internalSrcAlias } = appContext;
|
182
202
|
const { fileSystemRoutes, nestedRoutesEntry } = entrypoint;
|
183
203
|
if (fileSystemRoutes && nestedRoutesEntry) {
|
184
|
-
const rootLayoutPath =
|
185
|
-
const rootLayoutFile = (0,
|
204
|
+
const rootLayoutPath = path.join(nestedRoutesEntry, "layout");
|
205
|
+
const rootLayoutFile = (0, import_utils.findExists)([
|
186
206
|
".js",
|
187
207
|
".ts",
|
188
208
|
".jsx",
|
189
209
|
".tsx"
|
190
210
|
].map((ext) => `${rootLayoutPath}${ext}`));
|
191
211
|
if (rootLayoutFile) {
|
192
|
-
const rootLayoutBuffer = await
|
212
|
+
const rootLayoutBuffer = await import_utils.fs.readFile(rootLayoutFile);
|
193
213
|
const rootLayout = rootLayoutBuffer.toString();
|
194
|
-
const [, moduleExports] = await (0,
|
214
|
+
const [, moduleExports] = await (0, import_utils2.parseModule)({
|
195
215
|
source: rootLayout.toString(),
|
196
216
|
filename: rootLayoutFile
|
197
217
|
});
|
198
|
-
const hasAppConfig = moduleExports.some((e) => e.n ===
|
199
|
-
const generateLayoutPath = (0,
|
218
|
+
const hasAppConfig = moduleExports.some((e) => e.n === import_constants.APP_CONFIG_NAME);
|
219
|
+
const generateLayoutPath = (0, import_utils2.replaceWithAlias)(srcDirectory, rootLayoutFile, internalSrcAlias);
|
200
220
|
if (hasAppConfig) {
|
201
221
|
imports.push({
|
202
222
|
value: generateLayoutPath,
|
203
223
|
specifiers: [
|
204
224
|
{
|
205
|
-
imported:
|
225
|
+
imported: import_constants.APP_CONFIG_NAME
|
206
226
|
}
|
207
227
|
]
|
208
228
|
});
|
209
229
|
}
|
210
|
-
const hasAppInit = moduleExports.some((e) => e.n ===
|
230
|
+
const hasAppInit = moduleExports.some((e) => e.n === import_constants.APP_INIT_EXPORTED);
|
211
231
|
if (hasAppInit) {
|
212
232
|
imports.push({
|
213
233
|
value: generateLayoutPath,
|
214
234
|
specifiers: [
|
215
235
|
{
|
216
|
-
imported:
|
217
|
-
local:
|
236
|
+
imported: import_constants.APP_INIT_EXPORTED,
|
237
|
+
local: import_constants.APP_INIT_IMPORTED
|
218
238
|
}
|
219
239
|
]
|
220
240
|
});
|
@@ -239,12 +259,12 @@ const _default = ({ bundler }) => ({
|
|
239
259
|
const { appDirectory } = appContext;
|
240
260
|
const { filename, eventType } = e;
|
241
261
|
const isPageFile = (name) => pagesDir.some((pageDir) => name.includes(pageDir));
|
242
|
-
const absoluteFilePath =
|
243
|
-
const isRouteComponent = isPageFile(absoluteFilePath) && (0,
|
262
|
+
const absoluteFilePath = path.resolve(appDirectory, filename);
|
263
|
+
const isRouteComponent = isPageFile(absoluteFilePath) && (0, import_utils2.isPageComponentFile)(absoluteFilePath);
|
244
264
|
if (isRouteComponent && (eventType === "add" || eventType === "unlink")) {
|
245
265
|
const resolvedConfig = api.useResolvedConfigContext();
|
246
|
-
const { generateCode } = await Promise.resolve().then(() =>
|
247
|
-
const entrypoints = (0,
|
266
|
+
const { generateCode } = await Promise.resolve().then(() => __toESM(require("./generateCode")));
|
267
|
+
const entrypoints = (0, import_lodash.cloneDeep)(originEntrypoints);
|
248
268
|
generateCode(appContext, resolvedConfig, entrypoints, api);
|
249
269
|
}
|
250
270
|
}
|
@@ -1,25 +1,46 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
9
17
|
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var isDefaultExportFunction_exports = {};
|
30
|
+
__export(isDefaultExportFunction_exports, {
|
31
|
+
isDefaultExportFunction: () => isDefaultExportFunction
|
10
32
|
});
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
const
|
17
|
-
const isFunction = (node) => _types.isFunctionDeclaration(node) || _types.isFunctionExpression(node) || _types.isArrowFunctionExpression(node);
|
33
|
+
module.exports = __toCommonJS(isDefaultExportFunction_exports);
|
34
|
+
var import_fs = __toESM(require("fs"));
|
35
|
+
var import_parser = require("@babel/parser");
|
36
|
+
var import_traverse = __toESM(require("@babel/traverse"));
|
37
|
+
var t = __toESM(require("@babel/types"));
|
38
|
+
const isFunction = (node) => t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
|
18
39
|
const isDefaultExportFunction = (file) => {
|
19
|
-
if (!file || !
|
40
|
+
if (!file || !import_fs.default.existsSync(file)) {
|
20
41
|
return false;
|
21
42
|
}
|
22
|
-
const ast = (0,
|
43
|
+
const ast = (0, import_parser.parse)(import_fs.default.readFileSync(file, "utf8"), {
|
23
44
|
sourceType: "unambiguous",
|
24
45
|
plugins: [
|
25
46
|
"jsx",
|
@@ -44,7 +65,7 @@ const isDefaultExportFunction = (file) => {
|
|
44
65
|
]
|
45
66
|
});
|
46
67
|
let isExportFunction = false;
|
47
|
-
(0,
|
68
|
+
(0, import_traverse.default)(ast, {
|
48
69
|
ExportDefaultDeclaration: (path) => {
|
49
70
|
const { declaration } = path.node;
|
50
71
|
if (isFunction(declaration)) {
|
@@ -54,3 +75,7 @@ const isDefaultExportFunction = (file) => {
|
|
54
75
|
});
|
55
76
|
return isExportFunction;
|
56
77
|
};
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
79
|
+
0 && (module.exports = {
|
80
|
+
isDefaultExportFunction
|
81
|
+
});
|
@@ -1,13 +1,26 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
9
15
|
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var makeLegalIdentifier_exports = {};
|
20
|
+
__export(makeLegalIdentifier_exports, {
|
21
|
+
makeLegalIdentifier: () => makeLegalIdentifier
|
10
22
|
});
|
23
|
+
module.exports = __toCommonJS(makeLegalIdentifier_exports);
|
11
24
|
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
25
|
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
26
|
const forbidList = new Set(`${reservedWords} ${builtins}`.split(" "));
|
@@ -18,3 +31,7 @@ function makeLegalIdentifier(str) {
|
|
18
31
|
}
|
19
32
|
return identifier || "_";
|
20
33
|
}
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
35
|
+
0 && (module.exports = {
|
36
|
+
makeLegalIdentifier
|
37
|
+
});
|