@modern-js/app-tools 2.58.2 → 2.59.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/builder/builder-rspack/adapterCopy.js +1 -1
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +1 -1
- package/dist/cjs/builder/generator/index.js +2 -3
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +8 -13
- package/dist/cjs/builder/shared/builderPlugins/index.js +1 -3
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +1 -1
- package/dist/cjs/commands/build.js +2 -2
- package/dist/cjs/commands/dev.js +6 -5
- package/dist/cjs/commands/index.js +1 -1
- package/dist/cjs/commands/serve.js +4 -3
- package/dist/cjs/config/legacy/index.js +3 -3
- package/dist/cjs/esm/register-esm.mjs +2 -3
- package/dist/cjs/esm/utils.mjs +2 -2
- package/dist/cjs/index.js +17 -10
- package/dist/cjs/locale/index.js +1 -1
- package/dist/cjs/plugins/analyze/getFileSystemEntry.js +50 -44
- package/dist/cjs/plugins/analyze/getServerRoutes.js +2 -2
- package/dist/cjs/plugins/analyze/index.js +6 -6
- package/dist/cjs/plugins/analyze/utils.js +1 -1
- package/dist/cjs/plugins/deploy/dependencies/index.js +1 -1
- package/dist/cjs/plugins/deploy/dependencies/utils.js +2 -2
- package/dist/cjs/plugins/deploy/index.js +2 -2
- package/dist/cjs/plugins/deploy/platforms/netlify.js +1 -1
- package/dist/cjs/plugins/deploy/platforms/node.js +1 -1
- package/dist/cjs/plugins/deploy/platforms/vercel.js +1 -1
- package/dist/cjs/plugins/serverBuild.js +2 -2
- package/dist/cjs/utils/createServer.js +1 -1
- package/dist/esm/builder/builder-rspack/adapterCopy.js +166 -0
- package/dist/esm/builder/builder-rspack/index.js +34 -0
- package/dist/esm/builder/builder-webpack/adapterModern.js +29 -0
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +43 -0
- package/dist/esm/builder/builder-webpack/index.js +52 -0
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +37 -0
- package/dist/esm/builder/generator/getBuilderEnvironments.js +81 -0
- package/dist/esm/builder/generator/index.js +93 -0
- package/dist/esm/builder/index.js +45 -0
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +85 -0
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +126 -0
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +261 -0
- package/dist/esm/builder/shared/builderPlugins/index.js +3 -0
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +51 -0
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +37 -0
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +314 -0
- package/dist/esm/builder/shared/bundlerPlugins/index.js +3 -0
- package/dist/esm/builder/shared/createCopyInfo.js +14 -0
- package/dist/esm/builder/shared/index.js +3 -0
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +7 -0
- package/dist/esm/builder/shared/types.js +0 -0
- package/dist/esm/commands/build.js +140 -0
- package/dist/esm/commands/deploy.js +48 -0
- package/dist/esm/commands/dev.js +193 -0
- package/dist/esm/commands/index.js +411 -0
- package/dist/esm/commands/inspect.js +28 -0
- package/dist/esm/commands/serve.js +94 -0
- package/dist/esm/config/default.js +190 -0
- package/dist/esm/config/index.js +3 -0
- package/dist/esm/config/initialize/index.js +9 -0
- package/dist/esm/config/initialize/inits.js +89 -0
- package/dist/esm/config/legacy/createHtmlConfig.js +21 -0
- package/dist/esm/config/legacy/createOutputConfig.js +45 -0
- package/dist/esm/config/legacy/createSourceConfig.js +46 -0
- package/dist/esm/config/legacy/createToolsConfig.js +28 -0
- package/dist/esm/config/legacy/index.js +43 -0
- package/dist/esm/defineConfig.js +16 -0
- package/dist/esm/esm/esbuild-loader.mjs +20 -0
- package/dist/esm/esm/register-esm.mjs +66 -0
- package/dist/esm/esm/ts-node-loader.mjs +21 -0
- package/dist/esm/esm/utils.mjs +43 -0
- package/dist/esm/exports/server.js +4 -0
- package/dist/esm/hooks.js +34 -0
- package/dist/esm/index.js +246 -0
- package/dist/esm/locale/en.js +43 -0
- package/dist/esm/locale/index.js +12 -0
- package/dist/esm/locale/zh.js +43 -0
- package/dist/esm/plugins/analyze/constants.js +14 -0
- package/dist/esm/plugins/analyze/getBundleEntry.js +102 -0
- package/dist/esm/plugins/analyze/getFileSystemEntry.js +266 -0
- package/dist/esm/plugins/analyze/getHtmlTemplate.js +178 -0
- package/dist/esm/plugins/analyze/getServerRoutes.js +132 -0
- package/dist/esm/plugins/analyze/index.js +380 -0
- package/dist/esm/plugins/analyze/isDefaultExportFunction.js +49 -0
- package/dist/esm/plugins/analyze/templates.js +6 -0
- package/dist/esm/plugins/analyze/utils.js +101 -0
- package/dist/esm/plugins/deploy/dependencies/index.js +615 -0
- package/dist/esm/plugins/deploy/dependencies/utils.js +421 -0
- package/dist/esm/plugins/deploy/exports.js +4 -0
- package/dist/esm/plugins/deploy/index.js +135 -0
- package/dist/esm/plugins/deploy/platforms/netlify-entry.js +11 -0
- package/dist/esm/plugins/deploy/platforms/netlify-entry.mjs +1 -0
- package/dist/esm/plugins/deploy/platforms/netlify-handler.js +205 -0
- package/dist/esm/plugins/deploy/platforms/netlify.js +327 -0
- package/dist/esm/plugins/deploy/platforms/node-entry.js +108 -0
- package/dist/esm/plugins/deploy/platforms/node.js +161 -0
- package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm/plugins/deploy/platforms/vercel-entry.js +11 -0
- package/dist/esm/plugins/deploy/platforms/vercel-entry.mjs +3 -0
- package/dist/esm/plugins/deploy/platforms/vercel-handler.js +206 -0
- package/dist/esm/plugins/deploy/platforms/vercel.js +261 -0
- package/dist/esm/plugins/deploy/utils.js +47 -0
- package/dist/esm/plugins/initialize/index.js +119 -0
- package/dist/esm/plugins/serverBuild.js +87 -0
- 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 +1 -0
- 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 +3 -0
- 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 +122 -0
- package/dist/esm/utils/createServer.js +58 -0
- package/dist/esm/utils/env.js +16 -0
- package/dist/esm/utils/generateWatchFiles.js +71 -0
- package/dist/esm/utils/getSelectedEntries.js +67 -0
- package/dist/esm/utils/loadPlugins.js +74 -0
- package/dist/esm/utils/printInstructions.js +32 -0
- package/dist/esm/utils/register.js +188 -0
- package/dist/esm/utils/restart.js +67 -0
- package/dist/esm/utils/routes.js +42 -0
- package/dist/esm/utils/types.js +0 -0
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +67 -0
- package/dist/esm-node/builder/builder-rspack/index.js +12 -0
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +26 -0
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +41 -0
- package/dist/esm-node/builder/builder-webpack/index.js +20 -0
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +44 -0
- package/dist/esm-node/builder/generator/getBuilderEnvironments.js +60 -0
- package/dist/esm-node/builder/generator/index.js +36 -0
- package/dist/esm-node/builder/index.js +11 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +48 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +60 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +151 -0
- package/dist/esm-node/builder/shared/builderPlugins/index.js +3 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +30 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +31 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +228 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/index.js +3 -0
- package/dist/esm-node/builder/shared/createCopyInfo.js +14 -0
- package/dist/esm-node/builder/shared/index.js +3 -0
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +7 -0
- package/dist/esm-node/builder/shared/types.js +0 -0
- package/dist/esm-node/commands/build.js +64 -0
- package/dist/esm-node/commands/deploy.js +12 -0
- package/dist/esm-node/commands/dev.js +105 -0
- package/dist/esm-node/commands/index.js +92 -0
- package/dist/esm-node/commands/inspect.js +15 -0
- package/dist/esm-node/commands/serve.js +52 -0
- package/dist/esm-node/config/default.js +197 -0
- package/dist/esm-node/config/index.js +3 -0
- package/dist/esm-node/config/initialize/index.js +9 -0
- package/dist/esm-node/config/initialize/inits.js +79 -0
- package/dist/esm-node/config/legacy/createHtmlConfig.js +21 -0
- package/dist/esm-node/config/legacy/createOutputConfig.js +45 -0
- package/dist/esm-node/config/legacy/createSourceConfig.js +29 -0
- package/dist/esm-node/config/legacy/createToolsConfig.js +28 -0
- package/dist/esm-node/config/legacy/index.js +43 -0
- package/dist/esm-node/defineConfig.js +13 -0
- package/dist/esm-node/esm/esbuild-loader.mjs +20 -0
- package/dist/esm-node/esm/register-esm.mjs +66 -0
- package/dist/esm-node/esm/ts-node-loader.mjs +21 -0
- package/dist/esm-node/esm/utils.mjs +43 -0
- package/dist/esm-node/exports/server.js +4 -0
- package/dist/esm-node/hooks.js +34 -0
- package/dist/esm-node/index.js +131 -0
- package/dist/esm-node/locale/en.js +43 -0
- package/dist/esm-node/locale/index.js +12 -0
- package/dist/esm-node/locale/zh.js +43 -0
- package/dist/esm-node/plugins/analyze/constants.js +14 -0
- package/dist/esm-node/plugins/analyze/getBundleEntry.js +61 -0
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +106 -0
- package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +74 -0
- package/dist/esm-node/plugins/analyze/getServerRoutes.js +132 -0
- package/dist/esm-node/plugins/analyze/index.js +166 -0
- package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +47 -0
- package/dist/esm-node/plugins/analyze/templates.js +24 -0
- package/dist/esm-node/plugins/analyze/utils.js +68 -0
- package/dist/esm-node/plugins/deploy/dependencies/index.js +202 -0
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +137 -0
- package/dist/esm-node/plugins/deploy/exports.js +4 -0
- package/dist/esm-node/plugins/deploy/index.js +44 -0
- package/dist/esm-node/plugins/deploy/platforms/netlify-entry.js +11 -0
- package/dist/esm-node/plugins/deploy/platforms/netlify-entry.mjs +1 -0
- package/dist/esm-node/plugins/deploy/platforms/netlify-handler.js +71 -0
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +117 -0
- package/dist/esm-node/plugins/deploy/platforms/node-entry.js +44 -0
- package/dist/esm-node/plugins/deploy/platforms/node.js +72 -0
- package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel-entry.js +11 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel-entry.mjs +3 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel-handler.js +72 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +129 -0
- package/dist/esm-node/plugins/deploy/utils.js +44 -0
- package/dist/esm-node/plugins/initialize/index.js +84 -0
- package/dist/esm-node/plugins/serverBuild.js +58 -0
- 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 +1 -0
- 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 +3 -0
- 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 +49 -0
- package/dist/esm-node/utils/createServer.js +26 -0
- package/dist/esm-node/utils/env.js +16 -0
- package/dist/esm-node/utils/generateWatchFiles.js +30 -0
- package/dist/esm-node/utils/getSelectedEntries.js +34 -0
- package/dist/esm-node/utils/loadPlugins.js +22 -0
- package/dist/esm-node/utils/printInstructions.js +11 -0
- package/dist/esm-node/utils/register.js +96 -0
- package/dist/esm-node/utils/restart.js +22 -0
- package/dist/esm-node/utils/routes.js +21 -0
- package/dist/esm-node/utils/types.js +0 -0
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +1 -1
- package/dist/types/builder/generator/index.d.ts +2 -2
- package/dist/types/builder/shared/builderPlugins/index.d.ts +0 -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/loaders/serverModuleLoader.d.ts +1 -1
- package/dist/types/builder/shared/types.d.ts +1 -1
- package/dist/types/commands/build.d.ts +1 -1
- package/dist/types/commands/dev.d.ts +1 -1
- package/dist/types/commands/inspect.d.ts +1 -1
- package/dist/types/config/default.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
- package/dist/types/plugins/analyze/getFileSystemEntry.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/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 +2 -2
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/types/legacyConfig/index.d.ts +3 -3
- package/dist/types/types/legacyConfig/tools.d.ts +1 -1
- package/dist/types/utils/printInstructions.d.ts +1 -1
- package/package.json +20 -20
- package/dist/cjs/builder/shared/builderPlugins/adapterWorker.js +0 -51
- package/dist/types/builder/shared/builderPlugins/adapterWorker.d.ts +0 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { chalk, inquirer } from "@modern-js/utils";
|
|
2
|
+
import { i18n, localeKeys } from "../locale";
|
|
3
|
+
const getSelectedEntries = async (entry, entrypoints) => {
|
|
4
|
+
const entryNames = entrypoints.map((e) => e.entryName);
|
|
5
|
+
if (!entry) {
|
|
6
|
+
return entryNames;
|
|
7
|
+
}
|
|
8
|
+
if (typeof entry === "boolean") {
|
|
9
|
+
const { selected } = await inquirer.prompt([
|
|
10
|
+
{
|
|
11
|
+
type: "checkbox",
|
|
12
|
+
name: "selected",
|
|
13
|
+
choices: entryNames,
|
|
14
|
+
message: i18n.t(localeKeys.command.dev.selectEntry),
|
|
15
|
+
validate(answer) {
|
|
16
|
+
if (answer.length < 1) {
|
|
17
|
+
return i18n.t(localeKeys.command.dev.requireEntry);
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]);
|
|
23
|
+
return selected;
|
|
24
|
+
}
|
|
25
|
+
entry.forEach((name) => {
|
|
26
|
+
if (!entryNames.includes(name)) {
|
|
27
|
+
throw new Error(`Can not found entry ${chalk.yellow(name)}, the entry should be one of ${chalk.yellow(entryNames.join(", "))}`);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return entry;
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
getSelectedEntries
|
|
34
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { loadServerPlugins as loadServerPluginInstances } from "@modern-js/prod-server";
|
|
2
|
+
async function getServerPlugins(api, metaName = "modern-js") {
|
|
3
|
+
const runner = api.useHookRunners();
|
|
4
|
+
const { plugins } = await runner._internalServerPlugins({
|
|
5
|
+
plugins: []
|
|
6
|
+
});
|
|
7
|
+
const filtedPlugins = plugins.filter((plugin) => plugin.name.includes(metaName));
|
|
8
|
+
api.setAppContext({
|
|
9
|
+
...api.useAppContext(),
|
|
10
|
+
serverPlugins: filtedPlugins
|
|
11
|
+
});
|
|
12
|
+
return filtedPlugins;
|
|
13
|
+
}
|
|
14
|
+
async function loadServerPlugins(api, appDirectory, metaName) {
|
|
15
|
+
const plugins = await getServerPlugins(api, metaName);
|
|
16
|
+
const instances = await loadServerPluginInstances(plugins, appDirectory);
|
|
17
|
+
return instances;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
getServerPlugins,
|
|
21
|
+
loadServerPlugins
|
|
22
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { logger, prettyInstructions } from "@modern-js/utils";
|
|
2
|
+
const printInstructions = async (hookRunners, appContext, config) => {
|
|
3
|
+
const message = prettyInstructions(appContext, config);
|
|
4
|
+
const { instructions } = await hookRunners.beforePrintInstructions({
|
|
5
|
+
instructions: message
|
|
6
|
+
});
|
|
7
|
+
logger.log(instructions);
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
printInstructions
|
|
11
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fs, getAliasConfig, readTsConfigByFile } from "@modern-js/utils";
|
|
3
|
+
const registerEsbuild = async ({ isTsProject, tsConfig, distDir }) => {
|
|
4
|
+
const esbuildRegister = await import("esbuild-register/dist/node");
|
|
5
|
+
esbuildRegister.register({
|
|
6
|
+
tsconfigRaw: isTsProject ? tsConfig : void 0,
|
|
7
|
+
hookIgnoreNodeModules: true,
|
|
8
|
+
hookMatcher: (fileName) => !fileName.startsWith(distDir)
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
const registerCompiler = async (appDir, distDir, alias) => {
|
|
12
|
+
const TS_CONFIG_FILENAME = `tsconfig.json`;
|
|
13
|
+
const tsconfigPath = path.resolve(appDir, TS_CONFIG_FILENAME);
|
|
14
|
+
const isTsProject = await fs.pathExists(tsconfigPath);
|
|
15
|
+
const aliasConfig = getAliasConfig(alias, {
|
|
16
|
+
appDirectory: appDir,
|
|
17
|
+
tsconfigPath
|
|
18
|
+
});
|
|
19
|
+
const { paths = {}, absoluteBaseUrl = "./" } = aliasConfig;
|
|
20
|
+
const tsPaths = Object.keys(paths).reduce((o, key) => {
|
|
21
|
+
let tsPath = paths[key];
|
|
22
|
+
if (typeof tsPath === "string" && key.startsWith("@") && tsPath.startsWith("@")) {
|
|
23
|
+
try {
|
|
24
|
+
tsPath = require.resolve(tsPath, {
|
|
25
|
+
paths: [
|
|
26
|
+
process.cwd(),
|
|
27
|
+
...module.paths
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (typeof tsPath === "string" && path.isAbsolute(tsPath)) {
|
|
34
|
+
tsPath = path.relative(absoluteBaseUrl, tsPath);
|
|
35
|
+
}
|
|
36
|
+
if (typeof tsPath === "string") {
|
|
37
|
+
tsPath = [
|
|
38
|
+
tsPath
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
...o,
|
|
43
|
+
[`${key}`]: tsPath
|
|
44
|
+
};
|
|
45
|
+
}, {});
|
|
46
|
+
let tsConfig = {};
|
|
47
|
+
if (isTsProject) {
|
|
48
|
+
tsConfig = readTsConfigByFile(tsconfigPath);
|
|
49
|
+
}
|
|
50
|
+
const { MODERN_NODE_LOADER } = process.env;
|
|
51
|
+
if (MODERN_NODE_LOADER !== "esbuild") {
|
|
52
|
+
try {
|
|
53
|
+
const tsNode = await import("ts-node");
|
|
54
|
+
const tsNodeOptions = tsConfig["ts-node"];
|
|
55
|
+
if (isTsProject) {
|
|
56
|
+
tsNode.register({
|
|
57
|
+
project: tsconfigPath,
|
|
58
|
+
scope: true,
|
|
59
|
+
// for env.d.ts, https://www.npmjs.com/package/ts-node#missing-types
|
|
60
|
+
files: true,
|
|
61
|
+
transpileOnly: true,
|
|
62
|
+
ignore: [
|
|
63
|
+
"(?:^|/)node_modules/",
|
|
64
|
+
`(?:^|/)${path.relative(appDir, distDir)}/`
|
|
65
|
+
],
|
|
66
|
+
...tsNodeOptions
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
await registerEsbuild({
|
|
71
|
+
isTsProject,
|
|
72
|
+
tsConfig,
|
|
73
|
+
distDir
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
await registerEsbuild({
|
|
78
|
+
isTsProject,
|
|
79
|
+
tsConfig,
|
|
80
|
+
distDir
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const tsConfigPaths = (await import("@modern-js/utils/tsconfig-paths")).default;
|
|
84
|
+
if (await fs.pathExists(appDir)) {
|
|
85
|
+
const loaderRes = tsConfigPaths.loadConfig(appDir);
|
|
86
|
+
if (loaderRes.resultType === "success") {
|
|
87
|
+
tsConfigPaths.register({
|
|
88
|
+
baseUrl: absoluteBaseUrl || "./",
|
|
89
|
+
paths: tsPaths
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
export {
|
|
95
|
+
registerCompiler
|
|
96
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { cli } from "@modern-js/core";
|
|
2
|
+
import { chalk, clearConsole, getFullArgv, logger, program } from "@modern-js/utils";
|
|
3
|
+
async function restart(hooksRunner, filename) {
|
|
4
|
+
clearConsole();
|
|
5
|
+
logger.info(`Restart because ${chalk.yellow(filename)} is changed...
|
|
6
|
+
`);
|
|
7
|
+
let hasGetError = false;
|
|
8
|
+
await hooksRunner.beforeRestart();
|
|
9
|
+
try {
|
|
10
|
+
await cli.init(cli.getPrevInitOptions());
|
|
11
|
+
} catch (err) {
|
|
12
|
+
console.error(err);
|
|
13
|
+
hasGetError = true;
|
|
14
|
+
} finally {
|
|
15
|
+
if (!hasGetError) {
|
|
16
|
+
program.parse(getFullArgv());
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
restart
|
|
22
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fs, MAIN_ENTRY_NAME, ROUTE_SPEC_FILE } from "@modern-js/utils";
|
|
3
|
+
const generateRoutes = async (appContext) => {
|
|
4
|
+
const { serverRoutes, distDirectory } = appContext;
|
|
5
|
+
const output = JSON.stringify({
|
|
6
|
+
routes: serverRoutes
|
|
7
|
+
}, null, 2);
|
|
8
|
+
await fs.outputFile(path.join(distDirectory, ROUTE_SPEC_FILE), output);
|
|
9
|
+
};
|
|
10
|
+
const getPathWithoutExt = (filename) => {
|
|
11
|
+
const extname = path.extname(filename);
|
|
12
|
+
return filename.slice(0, -extname.length);
|
|
13
|
+
};
|
|
14
|
+
const isMainEntry = (entryName, mainEntryName) => {
|
|
15
|
+
return entryName === (mainEntryName || MAIN_ENTRY_NAME);
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
generateRoutes,
|
|
19
|
+
getPathWithoutExt,
|
|
20
|
+
isMainEntry
|
|
21
|
+
};
|
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Bundler, IAppContext
|
|
1
|
+
import type { AppNormalizedConfig, Bundler, IAppContext } from '../../types';
|
|
2
2
|
export declare function createBuilderProviderConfig<B extends Bundler>(resolveConfig: AppNormalizedConfig<B>, appContext: IAppContext): Omit<AppNormalizedConfig<B>, 'plugins'>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { BuilderOptions } from '../shared';
|
|
1
|
+
import { type BundlerType, type UniBuilderInstance } from '@modern-js/uni-builder';
|
|
3
2
|
import type { Bundler } from '../../types';
|
|
3
|
+
import type { BuilderOptions } from '../shared';
|
|
4
4
|
/**
|
|
5
5
|
* @param options BuilderOptions
|
|
6
6
|
* @param bundlerType BundlerType
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Rspack, webpack
|
|
1
|
+
import type { HtmlWebpackPlugin, Rspack, webpack } from '@modern-js/uni-builder';
|
|
2
2
|
export declare class HtmlAsyncChunkPlugin {
|
|
3
3
|
name: string;
|
|
4
4
|
htmlWebpackPlugin: typeof HtmlWebpackPlugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Rspack, webpack
|
|
1
|
+
import type { HtmlWebpackPlugin, Rspack, webpack } from '@modern-js/uni-builder';
|
|
2
2
|
export declare class BottomTemplatePlugin {
|
|
3
3
|
htmlWebpackPlugin: typeof HtmlWebpackPlugin;
|
|
4
4
|
bottomTemplateReg: RegExp;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Rspack, webpack
|
|
1
|
+
import type { HtmlWebpackPlugin, Rspack, webpack } from '@modern-js/uni-builder';
|
|
2
2
|
import type { ScriptLoading } from '@rsbuild/core';
|
|
3
3
|
export interface RouteAssets {
|
|
4
4
|
[routeId: string]: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AppNormalizedConfig, Bundler, IAppContext } from '../../types';
|
|
2
2
|
export type BuilderOptions<B extends Bundler> = {
|
|
3
3
|
normalizedConfig: AppNormalizedConfig<B>;
|
|
4
4
|
appContext: IAppContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type PluginAPI } from '@modern-js/core';
|
|
2
|
-
import type { BuildOptions } from '../utils/types';
|
|
3
2
|
import type { AppTools } from '../types';
|
|
3
|
+
import type { BuildOptions } from '../utils/types';
|
|
4
4
|
export declare const build: (api: PluginAPI<AppTools<'shared'>>, options?: BuildOptions) => Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type PluginAPI } from '@modern-js/core';
|
|
2
2
|
import { type ApplyPlugins } from '@modern-js/server';
|
|
3
|
-
import type { DevOptions } from '../utils/types';
|
|
4
3
|
import type { AppTools } from '../types';
|
|
4
|
+
import type { DevOptions } from '../utils/types';
|
|
5
5
|
export interface ExtraServerOptions {
|
|
6
6
|
applyPlugins?: ApplyPlugins;
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PluginAPI } from '@modern-js/core';
|
|
2
|
-
import type { InspectOptions } from '../utils/types';
|
|
3
2
|
import type { AppTools } from '../types';
|
|
3
|
+
import type { InspectOptions } from '../utils/types';
|
|
4
4
|
export declare const inspect: (api: PluginAPI<AppTools<'shared'>>, options: InspectOptions) => Promise<import("@rsbuild/core").InspectConfigResult<"rspack">>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AppLegacyUserConfig, AppUserConfig, IAppContext } from '../types';
|
|
2
2
|
export declare function createDefaultConfig(appContext: IAppContext): AppUserConfig<'webpack'> | AppUserConfig<'rspack'>;
|
|
3
3
|
export declare function createLegacyDefaultConfig(appContext: IAppContext): AppLegacyUserConfig;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type AppToolsOptions = {
|
|
|
11
11
|
* Specify which bundler to use for the build.
|
|
12
12
|
* @default `webpack`
|
|
13
13
|
* */
|
|
14
|
-
bundler?: '
|
|
14
|
+
bundler?: 'rspack' | 'webpack' | 'experimental-rspack';
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* The core package of the framework, providing CLI commands, build capabilities, configuration parsing and more.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Entrypoint } from '@modern-js/types';
|
|
2
1
|
import type { CliHooksRunner } from '@modern-js/core';
|
|
2
|
+
import type { Entrypoint } from '@modern-js/types';
|
|
3
3
|
import type { AppNormalizedConfig, AppTools, IAppContext } from '../../types';
|
|
4
4
|
export declare const getBundleEntry: (hookRunners: CliHooksRunner<AppTools<'shared'>>, appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Entrypoint } from '@modern-js/types';
|
|
2
1
|
import type { CliHooksRunner } from '@modern-js/core';
|
|
2
|
+
import type { Entrypoint } from '@modern-js/types';
|
|
3
3
|
import type { AppNormalizedConfig, AppTools, IAppContext } from '../../types';
|
|
4
4
|
export type { Entrypoint };
|
|
5
5
|
export declare const getFileSystemEntry: (hookRunners: CliHooksRunner<AppTools<'shared'>>, appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PackageJson } from 'pkg-types';
|
|
2
1
|
import type { NodeFileTraceOptions } from '@vercel/nft';
|
|
2
|
+
import type { PackageJson } from 'pkg-types';
|
|
3
3
|
import { traceFiles as defaultTraceFiles } from './utils';
|
|
4
4
|
export type { NodeFileTraceOptions } from '@vercel/nft';
|
|
5
5
|
export { nodeFileTrace } from '@vercel/nft';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { BffUserConfig, ServerUserConfig } from '@modern-js/server-core';
|
|
2
|
+
import type { LooseRsbuildPlugin, UniBuilderPlugin } from '@modern-js/uni-builder';
|
|
3
3
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
4
4
|
import type { Bundler } from '../utils';
|
|
5
|
+
import type { DeployUserConfig } from './deploy';
|
|
6
|
+
import type { DevUserConfig } from './dev';
|
|
7
|
+
import type { ExperimentsUserConfig } from './experiments';
|
|
8
|
+
import type { HtmlUserConfig } from './html';
|
|
5
9
|
import type { OutputUserConfig } from './output';
|
|
10
|
+
import type { PerformanceUserConfig } from './performance';
|
|
11
|
+
import type { SecurityUserConfig } from './security';
|
|
6
12
|
import type { SourceUserConfig } from './source';
|
|
7
13
|
import type { TestingUserConfig } from './testing';
|
|
8
|
-
import type { DevUserConfig } from './dev';
|
|
9
14
|
import type { ToolsUserConfig } from './tools';
|
|
10
|
-
import type { HtmlUserConfig } from './html';
|
|
11
|
-
import type { SecurityUserConfig } from './security';
|
|
12
|
-
import type { DeployUserConfig } from './deploy';
|
|
13
|
-
import type { ExperimentsUserConfig } from './experiments';
|
|
14
|
-
import type { PerformanceUserConfig } from './performance';
|
|
15
15
|
export * from './output';
|
|
16
16
|
export interface RuntimeUserConfig {
|
|
17
17
|
[name: string]: any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UniBuilderConfig } from '@modern-js/uni-builder';
|
|
2
1
|
import type { SSGConfig } from '@modern-js/types';
|
|
2
|
+
import type { UniBuilderConfig } from '@modern-js/uni-builder';
|
|
3
3
|
import type { UnwrapBuilderConfig } from '../utils';
|
|
4
4
|
export interface OutputUserConfig extends UnwrapBuilderConfig<UniBuilderConfig, 'output'> {
|
|
5
5
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { JestConfig } from '@modern-js/types';
|
|
2
|
-
import type { PluginSwcOptions } from '@rsbuild/plugin-swc';
|
|
3
1
|
import type { PluginEsbuildOptions } from '@modern-js/rsbuild-plugin-esbuild';
|
|
2
|
+
import type { JestConfig } from '@modern-js/types';
|
|
4
3
|
import type { UniBuilderConfig } from '@modern-js/uni-builder';
|
|
5
|
-
import type {
|
|
4
|
+
import type { PluginSwcOptions } from '@rsbuild/plugin-swc';
|
|
5
|
+
import type { Bundler, UnwrapBuilderConfig } from '../utils';
|
|
6
6
|
export type Tailwindcss = Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
|
|
7
7
|
type BuilderToolsConfig = UnwrapBuilderConfig<UniBuilderConfig, 'tools'>;
|
|
8
8
|
export interface ToolsUserConfig<B extends Bundler = 'webpack'> extends Omit<BuilderToolsConfig, 'swc'> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { DevToolData, RegisterBuildPlatformResult } from '@modern-js/core';
|
|
1
2
|
import type { AsyncWaterfall, AsyncWorkflow, ParallelWorkflow } from '@modern-js/plugin';
|
|
2
3
|
import type { Entrypoint, HtmlPartials, NestedRouteForCli, PageRoute, RouteLegacy, ServerPlugin, ServerRoute } from '@modern-js/types';
|
|
3
|
-
import type {
|
|
4
|
-
import type { Rspack, webpack, Stats, MultiStats } from '@modern-js/uni-builder';
|
|
4
|
+
import type { MultiStats, Rspack, Stats, webpack } from '@modern-js/uni-builder';
|
|
5
5
|
import type { Bundler } from './utils';
|
|
6
6
|
export interface ImportSpecifier {
|
|
7
7
|
local?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NormalizedConfig, UserConfig } from '@modern-js/core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AppToolsNormalizedConfig, AppToolsUserConfig } from './config';
|
|
3
3
|
import type { AppToolsHooks } from './hooks';
|
|
4
|
-
import type {
|
|
4
|
+
import type { AppToolsLegacyNormalizedConfig, AppToolsLegacyUserConfig } from './legacyConfig';
|
|
5
5
|
import type { Bundler } from './utils';
|
|
6
6
|
export * from './hooks';
|
|
7
7
|
export * from './config';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BffUserConfig as LegacyBffUserConfig, ServerUserConfig as LegacyServerUserConfig } from '@modern-js/server-core';
|
|
2
|
+
import type { DeployLegacyUserConfig } from './deploy';
|
|
2
3
|
import type { DevUserLegacyConfig } from './dev';
|
|
3
4
|
import type { OutputLegacyUserConfig } from './output';
|
|
4
5
|
import type { SourceLegacyUserConfig } from './source';
|
|
5
|
-
import type { DeployLegacyUserConfig } from './deploy';
|
|
6
|
-
import type { ToolsLegacyUserConfig } from './tools';
|
|
7
6
|
import type { TestingLegacyUserConfig } from './testing';
|
|
7
|
+
import type { ToolsLegacyUserConfig } from './tools';
|
|
8
8
|
export type { DevUserLegacyConfig } from './dev';
|
|
9
9
|
export type { OutputLegacyUserConfig } from './output';
|
|
10
10
|
export type { DeployLegacyUserConfig } from './deploy';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DevServerOptions, JestConfig } from '@modern-js/types';
|
|
2
2
|
import type { UniBuilderConfig } from '@modern-js/uni-builder';
|
|
3
3
|
type BuilderToolsConfig = Required<UniBuilderConfig>['tools'];
|
|
4
4
|
export type ToolsLegacyUserConfig = BuilderToolsConfig & {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CliHooksRunner, IAppContext } from '@modern-js/core';
|
|
2
2
|
import type { AppNormalizedConfig, AppTools } from '../types';
|
|
3
3
|
export declare const printInstructions: (hookRunners: CliHooksRunner<AppTools<'shared'>>, appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.59.0",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@babel/parser": "^7.22.15",
|
|
78
78
|
"@babel/traverse": "^7.23.2",
|
|
79
79
|
"@babel/types": "^7.24.7",
|
|
80
|
-
"@rsbuild/core": "1.0.1-
|
|
80
|
+
"@rsbuild/core": "1.0.1-rc.4",
|
|
81
81
|
"@rsbuild/plugin-node-polyfill": "1.0.4",
|
|
82
82
|
"@swc/helpers": "0.5.3",
|
|
83
83
|
"@vercel/nft": "^0.26.4",
|
|
@@ -88,23 +88,23 @@
|
|
|
88
88
|
"mlly": "^1.6.1",
|
|
89
89
|
"pkg-types": "^1.1.0",
|
|
90
90
|
"std-env": "^3.7.0",
|
|
91
|
-
"@modern-js/
|
|
92
|
-
"@modern-js/
|
|
93
|
-
"@modern-js/plugin": "2.
|
|
94
|
-
"@modern-js/plugin-i18n": "2.
|
|
95
|
-
"@modern-js/plugin-
|
|
96
|
-
"@modern-js/
|
|
97
|
-
"@modern-js/prod-server": "2.
|
|
98
|
-
"@modern-js/
|
|
99
|
-
"@modern-js/
|
|
100
|
-
"@modern-js/server-
|
|
101
|
-
"@modern-js/types": "2.
|
|
102
|
-
"@modern-js/
|
|
103
|
-
"@modern-js/
|
|
104
|
-
"@modern-js/utils": "2.
|
|
91
|
+
"@modern-js/node-bundle-require": "2.59.0",
|
|
92
|
+
"@modern-js/plugin": "2.59.0",
|
|
93
|
+
"@modern-js/plugin-data-loader": "2.59.0",
|
|
94
|
+
"@modern-js/plugin-i18n": "2.59.0",
|
|
95
|
+
"@modern-js/plugin-lint": "2.59.0",
|
|
96
|
+
"@modern-js/core": "2.59.0",
|
|
97
|
+
"@modern-js/prod-server": "2.59.0",
|
|
98
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.59.0",
|
|
99
|
+
"@modern-js/server": "2.59.0",
|
|
100
|
+
"@modern-js/server-utils": "2.59.0",
|
|
101
|
+
"@modern-js/types": "2.59.0",
|
|
102
|
+
"@modern-js/uni-builder": "2.59.0",
|
|
103
|
+
"@modern-js/server-core": "2.59.0",
|
|
104
|
+
"@modern-js/utils": "2.59.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@rsbuild/plugin-swc": "1.0.1-
|
|
107
|
+
"@rsbuild/plugin-swc": "1.0.1-rc.4",
|
|
108
108
|
"@types/babel__traverse": "7.18.5",
|
|
109
109
|
"@types/jest": "^29",
|
|
110
110
|
"@types/node": "^16",
|
|
@@ -112,9 +112,9 @@
|
|
|
112
112
|
"ts-node": "^10.9.1",
|
|
113
113
|
"tsconfig-paths": "^4.2.0",
|
|
114
114
|
"typescript": "^5",
|
|
115
|
-
"webpack": "^5.
|
|
116
|
-
"@scripts/
|
|
117
|
-
"@scripts/
|
|
115
|
+
"webpack": "^5.94.0",
|
|
116
|
+
"@scripts/build": "2.59.0",
|
|
117
|
+
"@scripts/jest-config": "2.59.0"
|
|
118
118
|
},
|
|
119
119
|
"sideEffects": false,
|
|
120
120
|
"publishConfig": {
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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 });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var adapterWorker_exports = {};
|
|
20
|
-
__export(adapterWorker_exports, {
|
|
21
|
-
builderPluginAdapterWorker: () => builderPluginAdapterWorker
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(adapterWorker_exports);
|
|
24
|
-
var import_path = require("path");
|
|
25
|
-
var import_uni_builder = require("@modern-js/uni-builder");
|
|
26
|
-
const getDistPath = (outputConfig, type) => {
|
|
27
|
-
const { distPath } = outputConfig;
|
|
28
|
-
const ret = distPath[type];
|
|
29
|
-
if (typeof ret !== "string") {
|
|
30
|
-
throw new Error(`unknown key ${type} in "output.distPath"`);
|
|
31
|
-
}
|
|
32
|
-
return ret;
|
|
33
|
-
};
|
|
34
|
-
const builderPluginAdapterWorker = () => ({
|
|
35
|
-
name: "builder-plugin-adapter-worker",
|
|
36
|
-
setup(api) {
|
|
37
|
-
api.modifyBundlerChain(async (chain, { environment }) => {
|
|
38
|
-
const { config, name } = environment;
|
|
39
|
-
const isServiceWorker = name === import_uni_builder.SERVICE_WORKER_ENVIRONMENT_NAME;
|
|
40
|
-
if (isServiceWorker) {
|
|
41
|
-
const workerPath = getDistPath(config.output, "root");
|
|
42
|
-
const filename = import_path.posix.join(workerPath, `[name].js`);
|
|
43
|
-
chain.output.filename(filename).chunkFilename(filename).libraryTarget("commonjs2");
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
-
0 && (module.exports = {
|
|
50
|
-
builderPluginAdapterWorker
|
|
51
|
-
});
|