@modern-js/app-tools 2.58.1 → 2.58.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/builder/builder-rspack/adapterCopy.js +1 -1
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +0 -1
- package/dist/cjs/builder/builder-webpack/index.js +1 -1
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +1 -1
- package/dist/cjs/builder/generator/index.js +2 -2
- package/dist/cjs/builder/index.js +2 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +8 -13
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +2 -5
- package/dist/cjs/commands/build.js +21 -2
- package/dist/cjs/commands/dev.js +15 -5
- package/dist/cjs/commands/index.js +9 -9
- package/dist/cjs/commands/serve.js +4 -3
- package/dist/cjs/config/initialize/inits.js +4 -4
- package/dist/cjs/config/legacy/index.js +3 -3
- package/dist/cjs/esm/esbuild-loader.mjs +20 -0
- package/dist/cjs/esm/register-esm.mjs +66 -0
- package/dist/cjs/esm/ts-node-loader.mjs +21 -0
- package/dist/cjs/esm/utils.mjs +43 -0
- package/dist/cjs/index.js +8 -8
- package/dist/cjs/locale/index.js +1 -1
- package/dist/cjs/plugins/analyze/getServerRoutes.js +2 -2
- package/dist/cjs/plugins/analyze/index.js +9 -9
- package/dist/cjs/plugins/analyze/utils.js +1 -1
- package/dist/cjs/plugins/deploy/dependencies/index.js +2 -1
- package/dist/cjs/plugins/deploy/dependencies/utils.js +13 -2
- package/dist/cjs/plugins/deploy/index.js +2 -2
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +3 -0
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +1 -0
- package/dist/cjs/plugins/deploy/platforms/{netlifyEntry.js → netlify-handler.js} +6 -4
- package/dist/cjs/plugins/deploy/platforms/netlify.js +15 -6
- package/dist/cjs/plugins/deploy/platforms/node.js +14 -5
- package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +3 -0
- package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +3 -0
- package/dist/cjs/plugins/deploy/platforms/{vercelEntry.js → vercel-handler.js} +4 -1
- package/dist/cjs/plugins/deploy/platforms/vercel.js +15 -6
- package/dist/cjs/plugins/serverBuild.js +2 -2
- package/dist/cjs/utils/config.js +1 -1
- package/dist/cjs/utils/createServer.js +1 -1
- package/dist/cjs/utils/loadPlugins.js +1 -1
- package/dist/cjs/utils/register.js +50 -23
- package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -2
- package/dist/types/builder/builder-rspack/index.d.ts +1 -1
- package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -2
- package/dist/types/builder/builder-webpack/index.d.ts +1 -1
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +1 -1
- package/dist/types/builder/generator/index.d.ts +3 -3
- package/dist/types/builder/index.d.ts +1 -1
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
- package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
- package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +1 -1
- package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +1 -1
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -1
- package/dist/types/builder/shared/createCopyInfo.d.ts +1 -1
- package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +1 -1
- package/dist/types/builder/shared/types.d.ts +1 -1
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/dev.d.ts +3 -3
- package/dist/types/commands/index.d.ts +3 -3
- package/dist/types/commands/inspect.d.ts +1 -1
- package/dist/types/config/default.d.ts +1 -1
- package/dist/types/config/initialize/inits.d.ts +1 -1
- package/dist/types/config/legacy/createHtmlConfig.d.ts +1 -1
- package/dist/types/config/legacy/createOutputConfig.d.ts +1 -1
- package/dist/types/config/legacy/createSourceConfig.d.ts +1 -1
- package/dist/types/config/legacy/createToolsConfig.d.ts +1 -1
- package/dist/types/esm/esbuild-loader.d.mts +6 -0
- package/dist/types/esm/register-esm.d.mts +5 -0
- package/dist/types/esm/ts-node-loader.d.mts +6 -0
- package/dist/types/esm/utils.d.mts +6 -0
- package/dist/types/exports/server.d.ts +1 -1
- package/dist/types/hooks.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
- package/dist/types/plugins/analyze/index.d.ts +1 -1
- package/dist/types/plugins/deploy/dependencies/index.d.ts +1 -1
- package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -1
- package/dist/types/plugins/deploy/index.d.ts +2 -2
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify-handler.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/node.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
- package/dist/types/plugins/deploy/platforms/vercel-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/platforms/vercel-entry.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/vercel-handler.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/vercel.d.ts +1 -1
- package/dist/types/plugins/deploy/utils.d.ts +1 -1
- package/dist/types/plugins/initialize/index.d.ts +1 -1
- package/dist/types/plugins/serverBuild.d.ts +1 -1
- package/dist/types/types/config/index.d.ts +8 -8
- package/dist/types/types/config/output.d.ts +1 -1
- package/dist/types/types/config/tools.d.ts +3 -3
- package/dist/types/types/hooks.d.ts +3 -3
- package/dist/types/types/index.d.ts +3 -3
- package/dist/types/types/legacyConfig/index.d.ts +3 -3
- package/dist/types/types/legacyConfig/tools.d.ts +1 -1
- package/dist/types/utils/createServer.d.ts +1 -1
- package/dist/types/utils/generateWatchFiles.d.ts +1 -1
- package/dist/types/utils/getSelectedEntries.d.ts +1 -1
- package/dist/types/utils/loadPlugins.d.ts +3 -3
- package/dist/types/utils/printInstructions.d.ts +1 -1
- package/dist/types/utils/register.d.ts +2 -2
- package/dist/types/utils/restart.d.ts +2 -2
- package/lib/types.d.ts +15 -0
- package/package.json +20 -20
- package/dist/esm/builder/builder-rspack/adapterCopy.js +0 -166
- package/dist/esm/builder/builder-rspack/index.js +0 -34
- package/dist/esm/builder/builder-webpack/adapterModern.js +0 -29
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +0 -44
- package/dist/esm/builder/builder-webpack/index.js +0 -52
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -37
- package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -81
- package/dist/esm/builder/generator/index.js +0 -94
- package/dist/esm/builder/index.js +0 -45
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -85
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -270
- package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +0 -43
- package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -317
- package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
- package/dist/esm/builder/shared/createCopyInfo.js +0 -14
- package/dist/esm/builder/shared/index.js +0 -3
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/esm/builder/shared/types.js +0 -0
- package/dist/esm/commands/build.js +0 -117
- package/dist/esm/commands/deploy.js +0 -48
- package/dist/esm/commands/dev.js +0 -169
- package/dist/esm/commands/index.js +0 -411
- package/dist/esm/commands/inspect.js +0 -28
- package/dist/esm/commands/serve.js +0 -93
- package/dist/esm/config/default.js +0 -190
- package/dist/esm/config/index.js +0 -3
- package/dist/esm/config/initialize/index.js +0 -9
- package/dist/esm/config/initialize/inits.js +0 -85
- package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
- package/dist/esm/config/legacy/createOutputConfig.js +0 -45
- package/dist/esm/config/legacy/createSourceConfig.js +0 -46
- package/dist/esm/config/legacy/createToolsConfig.js +0 -28
- package/dist/esm/config/legacy/index.js +0 -43
- package/dist/esm/defineConfig.js +0 -16
- package/dist/esm/exports/server.js +0 -4
- package/dist/esm/hooks.js +0 -34
- package/dist/esm/index.js +0 -239
- package/dist/esm/locale/en.js +0 -43
- package/dist/esm/locale/index.js +0 -12
- package/dist/esm/locale/zh.js +0 -43
- package/dist/esm/plugins/analyze/constants.js +0 -14
- package/dist/esm/plugins/analyze/getBundleEntry.js +0 -102
- package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -238
- package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -178
- package/dist/esm/plugins/analyze/getServerRoutes.js +0 -132
- package/dist/esm/plugins/analyze/index.js +0 -380
- package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
- package/dist/esm/plugins/analyze/templates.js +0 -6
- package/dist/esm/plugins/analyze/utils.js +0 -101
- package/dist/esm/plugins/deploy/dependencies/index.js +0 -614
- package/dist/esm/plugins/deploy/dependencies/utils.js +0 -394
- package/dist/esm/plugins/deploy/exports.js +0 -4
- package/dist/esm/plugins/deploy/index.js +0 -135
- package/dist/esm/plugins/deploy/platforms/netlify.js +0 -299
- package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +0 -203
- package/dist/esm/plugins/deploy/platforms/node.js +0 -133
- package/dist/esm/plugins/deploy/platforms/nodeEntry.js +0 -108
- package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm/plugins/deploy/platforms/vercel.js +0 -233
- package/dist/esm/plugins/deploy/platforms/vercelEntry.js +0 -203
- package/dist/esm/plugins/deploy/utils.js +0 -47
- package/dist/esm/plugins/initialize/index.js +0 -119
- package/dist/esm/plugins/serverBuild.js +0 -87
- package/dist/esm/types/config/deploy.js +0 -0
- package/dist/esm/types/config/dev.js +0 -0
- package/dist/esm/types/config/experiments.js +0 -0
- package/dist/esm/types/config/html.js +0 -0
- package/dist/esm/types/config/index.js +0 -1
- package/dist/esm/types/config/output.js +0 -0
- package/dist/esm/types/config/performance.js +0 -0
- package/dist/esm/types/config/security.js +0 -0
- package/dist/esm/types/config/source.js +0 -0
- package/dist/esm/types/config/testing.js +0 -0
- package/dist/esm/types/config/tools.js +0 -0
- package/dist/esm/types/hooks.js +0 -0
- package/dist/esm/types/index.js +0 -3
- package/dist/esm/types/legacyConfig/deploy.js +0 -0
- package/dist/esm/types/legacyConfig/dev.js +0 -0
- package/dist/esm/types/legacyConfig/index.js +0 -0
- package/dist/esm/types/legacyConfig/output.js +0 -0
- package/dist/esm/types/legacyConfig/source.js +0 -0
- package/dist/esm/types/legacyConfig/testing.js +0 -0
- package/dist/esm/types/legacyConfig/tools.js +0 -0
- package/dist/esm/types/utils.js +0 -0
- package/dist/esm/utils/config.js +0 -122
- package/dist/esm/utils/createServer.js +0 -58
- package/dist/esm/utils/env.js +0 -16
- package/dist/esm/utils/generateWatchFiles.js +0 -71
- package/dist/esm/utils/getSelectedEntries.js +0 -67
- package/dist/esm/utils/loadPlugins.js +0 -69
- package/dist/esm/utils/printInstructions.js +0 -32
- package/dist/esm/utils/register.js +0 -129
- package/dist/esm/utils/restart.js +0 -67
- package/dist/esm/utils/routes.js +0 -42
- package/dist/esm/utils/types.js +0 -0
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +0 -67
- package/dist/esm-node/builder/builder-rspack/index.js +0 -12
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +0 -26
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +0 -42
- package/dist/esm-node/builder/builder-webpack/index.js +0 -20
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -44
- package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -60
- package/dist/esm-node/builder/generator/index.js +0 -37
- package/dist/esm-node/builder/index.js +0 -11
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -48
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -156
- package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +0 -27
- package/dist/esm-node/builder/shared/builderPlugins/index.js +0 -4
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -231
- package/dist/esm-node/builder/shared/bundlerPlugins/index.js +0 -3
- package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
- package/dist/esm-node/builder/shared/index.js +0 -3
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/esm-node/builder/shared/types.js +0 -0
- package/dist/esm-node/commands/build.js +0 -55
- package/dist/esm-node/commands/deploy.js +0 -12
- package/dist/esm-node/commands/dev.js +0 -95
- package/dist/esm-node/commands/index.js +0 -92
- package/dist/esm-node/commands/inspect.js +0 -15
- package/dist/esm-node/commands/serve.js +0 -51
- package/dist/esm-node/config/default.js +0 -197
- package/dist/esm-node/config/index.js +0 -3
- package/dist/esm-node/config/initialize/index.js +0 -9
- package/dist/esm-node/config/initialize/inits.js +0 -79
- package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
- package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
- package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
- package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
- package/dist/esm-node/config/legacy/index.js +0 -43
- package/dist/esm-node/defineConfig.js +0 -13
- package/dist/esm-node/exports/server.js +0 -4
- package/dist/esm-node/hooks.js +0 -34
- package/dist/esm-node/index.js +0 -124
- package/dist/esm-node/locale/en.js +0 -43
- package/dist/esm-node/locale/index.js +0 -12
- package/dist/esm-node/locale/zh.js +0 -43
- package/dist/esm-node/plugins/analyze/constants.js +0 -14
- package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -61
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -100
- package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -74
- package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -132
- package/dist/esm-node/plugins/analyze/index.js +0 -166
- package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
- package/dist/esm-node/plugins/analyze/templates.js +0 -24
- package/dist/esm-node/plugins/analyze/utils.js +0 -68
- package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -201
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -126
- package/dist/esm-node/plugins/deploy/exports.js +0 -4
- package/dist/esm-node/plugins/deploy/index.js +0 -44
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -108
- package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +0 -69
- package/dist/esm-node/plugins/deploy/platforms/node.js +0 -63
- package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +0 -44
- package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -120
- package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +0 -69
- package/dist/esm-node/plugins/deploy/utils.js +0 -44
- package/dist/esm-node/plugins/initialize/index.js +0 -84
- package/dist/esm-node/plugins/serverBuild.js +0 -58
- package/dist/esm-node/types/config/deploy.js +0 -0
- package/dist/esm-node/types/config/dev.js +0 -0
- package/dist/esm-node/types/config/experiments.js +0 -0
- package/dist/esm-node/types/config/html.js +0 -0
- package/dist/esm-node/types/config/index.js +0 -1
- package/dist/esm-node/types/config/output.js +0 -0
- package/dist/esm-node/types/config/performance.js +0 -0
- package/dist/esm-node/types/config/security.js +0 -0
- package/dist/esm-node/types/config/source.js +0 -0
- package/dist/esm-node/types/config/testing.js +0 -0
- package/dist/esm-node/types/config/tools.js +0 -0
- package/dist/esm-node/types/hooks.js +0 -0
- package/dist/esm-node/types/index.js +0 -3
- package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
- package/dist/esm-node/types/legacyConfig/dev.js +0 -0
- package/dist/esm-node/types/legacyConfig/index.js +0 -0
- package/dist/esm-node/types/legacyConfig/output.js +0 -0
- package/dist/esm-node/types/legacyConfig/source.js +0 -0
- package/dist/esm-node/types/legacyConfig/testing.js +0 -0
- package/dist/esm-node/types/legacyConfig/tools.js +0 -0
- package/dist/esm-node/types/utils.js +0 -0
- package/dist/esm-node/utils/config.js +0 -49
- package/dist/esm-node/utils/createServer.js +0 -26
- package/dist/esm-node/utils/env.js +0 -16
- package/dist/esm-node/utils/generateWatchFiles.js +0 -30
- package/dist/esm-node/utils/getSelectedEntries.js +0 -34
- package/dist/esm-node/utils/loadPlugins.js +0 -22
- package/dist/esm-node/utils/printInstructions.js +0 -11
- package/dist/esm-node/utils/register.js +0 -69
- package/dist/esm-node/utils/restart.js +0 -22
- package/dist/esm-node/utils/routes.js +0 -21
- package/dist/esm-node/utils/types.js +0 -0
- package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +0 -2
- package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +0 -2
- /package/dist/cjs/plugins/deploy/platforms/{nodeEntry.js → node-entry.js} +0 -0
- /package/dist/types/plugins/deploy/platforms/{nodeEntry.d.ts → node-entry.d.ts} +0 -0
@@ -1,49 +0,0 @@
|
|
1
|
-
import fs from "fs";
|
2
|
-
import { parse } from "@babel/parser";
|
3
|
-
import traverse from "@babel/traverse";
|
4
|
-
import * as t from "@babel/types";
|
5
|
-
var isFunction = function(node) {
|
6
|
-
return t.isFunctionDeclaration(node) || t.isFunctionExpression(node) || t.isArrowFunctionExpression(node);
|
7
|
-
};
|
8
|
-
var isDefaultExportFunction = function(file) {
|
9
|
-
if (!file || !fs.existsSync(file)) {
|
10
|
-
return false;
|
11
|
-
}
|
12
|
-
var ast = parse(fs.readFileSync(file, "utf8"), {
|
13
|
-
sourceType: "unambiguous",
|
14
|
-
plugins: [
|
15
|
-
"jsx",
|
16
|
-
"typescript",
|
17
|
-
"classProperties",
|
18
|
-
"dynamicImport",
|
19
|
-
"exportDefaultFrom",
|
20
|
-
"exportNamespaceFrom",
|
21
|
-
"decorators-legacy",
|
22
|
-
"functionBind",
|
23
|
-
"classPrivateMethods",
|
24
|
-
[
|
25
|
-
"pipelineOperator",
|
26
|
-
{
|
27
|
-
proposal: "minimal"
|
28
|
-
}
|
29
|
-
],
|
30
|
-
"optionalChaining",
|
31
|
-
"optionalCatchBinding",
|
32
|
-
"objectRestSpread",
|
33
|
-
"numericSeparator"
|
34
|
-
]
|
35
|
-
});
|
36
|
-
var isExportFunction = false;
|
37
|
-
traverse(ast, {
|
38
|
-
ExportDefaultDeclaration: function(path) {
|
39
|
-
var declaration = path.node.declaration;
|
40
|
-
if (isFunction(declaration)) {
|
41
|
-
isExportFunction = true;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
});
|
45
|
-
return isExportFunction;
|
46
|
-
};
|
47
|
-
export {
|
48
|
-
isDefaultExportFunction
|
49
|
-
};
|
@@ -1,6 +0,0 @@
|
|
1
|
-
var html = function(partials) {
|
2
|
-
return "\n<!DOCTYPE html>\n<html>\n<head>\n\n ".concat(partials.top.join("\n"), "\n\n ").concat(partials.head.join("\n"), '\n\n</head>\n\n<body>\n <div id="<%= mountId %>"><!--<?- html ?>--></div>\n ').concat(partials.body.join("\n"), "\n <!--<?- chunksMap.js ?>-->\n <!--<?- SSRDataScript ?>-->\n <!--<?- bottomTemplate ?>-->\n</body>\n\n</html>\n");
|
3
|
-
};
|
4
|
-
export {
|
5
|
-
html
|
6
|
-
};
|
@@ -1,101 +0,0 @@
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
-
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
3
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
4
|
-
import fs from "fs";
|
5
|
-
import path from "path";
|
6
|
-
import { normalizeToPosixPath, getCommand, JS_EXTENSIONS } from "@modern-js/utils";
|
7
|
-
import { transform } from "esbuild";
|
8
|
-
import { parse } from "es-module-lexer";
|
9
|
-
var walkDirectory = function(dir) {
|
10
|
-
return fs.readdirSync(dir).reduce(function(previous, filename) {
|
11
|
-
var filePath = path.join(dir, filename);
|
12
|
-
if (fs.statSync(filePath).isDirectory()) {
|
13
|
-
return _to_consumable_array(previous).concat(_to_consumable_array(walkDirectory(filePath)));
|
14
|
-
} else {
|
15
|
-
return _to_consumable_array(previous).concat([
|
16
|
-
filePath
|
17
|
-
]);
|
18
|
-
}
|
19
|
-
}, []);
|
20
|
-
};
|
21
|
-
var replaceWithAlias = function(base, filePath, alias) {
|
22
|
-
if (filePath.includes(base)) {
|
23
|
-
return normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
|
24
|
-
} else {
|
25
|
-
return filePath;
|
26
|
-
}
|
27
|
-
};
|
28
|
-
var parseModule = function() {
|
29
|
-
var _ref = _async_to_generator(function(param) {
|
30
|
-
var source, filename, content, result;
|
31
|
-
return _ts_generator(this, function(_state) {
|
32
|
-
switch (_state.label) {
|
33
|
-
case 0:
|
34
|
-
source = param.source, filename = param.filename;
|
35
|
-
content = source;
|
36
|
-
if (!JS_EXTENSIONS.some(function(ext) {
|
37
|
-
return filename.endsWith(ext);
|
38
|
-
}))
|
39
|
-
return [
|
40
|
-
3,
|
41
|
-
2
|
42
|
-
];
|
43
|
-
return [
|
44
|
-
4,
|
45
|
-
transform(content, {
|
46
|
-
loader: path.extname(filename).slice(1),
|
47
|
-
format: "esm"
|
48
|
-
})
|
49
|
-
];
|
50
|
-
case 1:
|
51
|
-
result = _state.sent();
|
52
|
-
content = result.code;
|
53
|
-
_state.label = 2;
|
54
|
-
case 2:
|
55
|
-
return [
|
56
|
-
4,
|
57
|
-
parse(content)
|
58
|
-
];
|
59
|
-
case 3:
|
60
|
-
return [
|
61
|
-
2,
|
62
|
-
_state.sent()
|
63
|
-
];
|
64
|
-
}
|
65
|
-
});
|
66
|
-
});
|
67
|
-
return function parseModule2(_) {
|
68
|
-
return _ref.apply(this, arguments);
|
69
|
-
};
|
70
|
-
}();
|
71
|
-
var getServerCombinedModueFile = function(internalDirectory, entryName) {
|
72
|
-
return path.join(internalDirectory, entryName, "server-loader-combined.js");
|
73
|
-
};
|
74
|
-
var checkIsBuildCommands = function() {
|
75
|
-
var buildCommands = [
|
76
|
-
"dev",
|
77
|
-
"start",
|
78
|
-
"build",
|
79
|
-
"inspect",
|
80
|
-
"deploy",
|
81
|
-
"dev-worker"
|
82
|
-
];
|
83
|
-
var command = getCommand();
|
84
|
-
return buildCommands.includes(command);
|
85
|
-
};
|
86
|
-
var isSubDirOrEqual = function(parent, child) {
|
87
|
-
if (parent === child) {
|
88
|
-
return true;
|
89
|
-
}
|
90
|
-
var relative = path.relative(parent, child);
|
91
|
-
var isSubdir = relative && !relative.startsWith("..") && !path.isAbsolute(relative);
|
92
|
-
return Boolean(isSubdir);
|
93
|
-
};
|
94
|
-
export {
|
95
|
-
checkIsBuildCommands,
|
96
|
-
getServerCombinedModueFile,
|
97
|
-
isSubDirOrEqual,
|
98
|
-
parseModule,
|
99
|
-
replaceWithAlias,
|
100
|
-
walkDirectory
|
101
|
-
};
|