@modern-js/app-tools 2.55.0 → 2.56.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.
Files changed (40) hide show
  1. package/dist/cjs/builder/generator/{createBuilderOptions.js → getBuilderEnvironments.js} +38 -21
  2. package/dist/cjs/builder/generator/index.js +6 -5
  3. package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +7 -14
  4. package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +6 -6
  5. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +4 -6
  6. package/dist/cjs/builder/shared/builderPlugins/adapterWorker.js +5 -3
  7. package/dist/cjs/commands/inspect.js +1 -2
  8. package/dist/cjs/config/default.js +0 -2
  9. package/dist/cjs/config/legacy/index.js +1 -0
  10. package/dist/cjs/plugins/analyze/getBundleEntry.js +2 -1
  11. package/dist/esm/builder/generator/{createBuilderOptions.js → getBuilderEnvironments.js} +34 -18
  12. package/dist/esm/builder/generator/index.js +9 -9
  13. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +7 -14
  14. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +7 -7
  15. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +6 -8
  16. package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +6 -4
  17. package/dist/esm/commands/inspect.js +1 -2
  18. package/dist/esm/config/default.js +0 -5
  19. package/dist/esm/config/legacy/index.js +1 -0
  20. package/dist/esm/plugins/analyze/getBundleEntry.js +2 -1
  21. package/dist/esm-node/builder/generator/getBuilderEnvironments.js +60 -0
  22. package/dist/esm-node/builder/generator/index.js +6 -5
  23. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +7 -14
  24. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +6 -6
  25. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +5 -7
  26. package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +5 -3
  27. package/dist/esm-node/commands/inspect.js +1 -2
  28. package/dist/esm-node/config/default.js +0 -2
  29. package/dist/esm-node/config/legacy/index.js +1 -0
  30. package/dist/esm-node/plugins/analyze/getBundleEntry.js +2 -1
  31. package/dist/types/builder/generator/getBuilderEnvironments.d.ts +5 -0
  32. package/dist/types/types/config/index.d.ts +2 -0
  33. package/dist/types/types/config/source.d.ts +6 -0
  34. package/package.json +22 -22
  35. package/dist/cjs/builder/generator/getBuilderTargets.js +0 -42
  36. package/dist/esm/builder/generator/getBuilderTargets.js +0 -18
  37. package/dist/esm-node/builder/generator/createBuilderOptions.js +0 -43
  38. package/dist/esm-node/builder/generator/getBuilderTargets.js +0 -18
  39. package/dist/types/builder/generator/createBuilderOptions.d.ts +0 -3
  40. package/dist/types/builder/generator/getBuilderTargets.d.ts +0 -3
@@ -16,12 +16,14 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var createBuilderOptions_exports = {};
20
- __export(createBuilderOptions_exports, {
21
- createBuilderOptions: () => createBuilderOptions
19
+ var getBuilderEnvironments_exports = {};
20
+ __export(getBuilderEnvironments_exports, {
21
+ getBuilderEnvironments: () => getBuilderEnvironments
22
22
  });
23
- module.exports = __toCommonJS(createBuilderOptions_exports);
24
- function createBuilderOptions(target, appContext) {
23
+ module.exports = __toCommonJS(getBuilderEnvironments_exports);
24
+ var import_utils = require("@modern-js/utils");
25
+ var import_uni_builder = require("@modern-js/uni-builder");
26
+ function getBuilderEnvironments(normalizedConfig, appContext) {
25
27
  const entries = {};
26
28
  const { entrypoints = [], checkedEntries } = appContext;
27
29
  for (const { entryName, internalEntry, entry } of entrypoints) {
@@ -42,26 +44,41 @@ function createBuilderOptions(target, appContext) {
42
44
  const v = entries[entry];
43
45
  serverEntries[entry] = v.map((entry2) => entry2.replace("index.jsx", "index.server.jsx"));
44
46
  }
45
- return {
46
- cwd: appContext.appDirectory,
47
- target,
48
- frameworkConfigPath: appContext.configFile || void 0,
49
- entry({ target: target2 }) {
50
- if (target2 === "web") {
51
- return entries;
47
+ const environments = {
48
+ web: {
49
+ output: {
50
+ target: "web"
51
+ },
52
+ source: {
53
+ entry: entries
52
54
  }
53
- if ([
54
- "node",
55
- "web-worker",
56
- "service-worker"
57
- ].includes(target2)) {
58
- return serverEntries;
59
- }
60
- return entries;
61
55
  }
62
56
  };
57
+ const useNodeTarget = (0, import_utils.isProd)() ? (0, import_utils.isUseSSRBundle)(normalizedConfig) : (0, import_utils.isSSR)(normalizedConfig);
58
+ if (useNodeTarget) {
59
+ environments.node = {
60
+ output: {
61
+ target: "node"
62
+ },
63
+ source: {
64
+ entry: serverEntries
65
+ }
66
+ };
67
+ }
68
+ const useWorkerTarget = (0, import_utils.isServiceWorker)(normalizedConfig);
69
+ if (useWorkerTarget) {
70
+ environments[import_uni_builder.SERVICE_WORKER_ENVIRONMENT_NAME] = {
71
+ output: {
72
+ target: "web-worker"
73
+ },
74
+ source: {
75
+ entry: serverEntries
76
+ }
77
+ };
78
+ }
79
+ return environments;
63
80
  }
64
81
  // Annotate the CommonJS export names for ESM import in node:
65
82
  0 && (module.exports = {
66
- createBuilderOptions
83
+ getBuilderEnvironments
67
84
  });
@@ -32,16 +32,17 @@ __export(generator_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(generator_exports);
34
34
  var import_uni_builder = require("@modern-js/uni-builder");
35
+ var import_core = require("@rsbuild/core");
35
36
  var import_createBuilderProviderConfig = require("./createBuilderProviderConfig");
36
- var import_getBuilderTargets = require("./getBuilderTargets");
37
- var import_createBuilderOptions = require("./createBuilderOptions");
37
+ var import_getBuilderEnvironments = require("./getBuilderEnvironments");
38
38
  async function generateBuilder(options, bundlerType) {
39
39
  const { normalizedConfig, appContext } = options;
40
40
  const builderConfig = (0, import_createBuilderProviderConfig.createBuilderProviderConfig)(normalizedConfig, appContext);
41
- const target = (0, import_getBuilderTargets.getBuilderTargets)(normalizedConfig);
42
- const builderOptions = (0, import_createBuilderOptions.createBuilderOptions)(target, appContext);
41
+ const environments = (0, import_getBuilderEnvironments.getBuilderEnvironments)(normalizedConfig, appContext);
42
+ builderConfig.environments = builderConfig.environments ? (0, import_core.mergeRsbuildConfig)(environments, builderConfig.environments) : environments;
43
43
  const builder = await (0, import_uni_builder.createUniBuilder)({
44
- ...builderOptions,
44
+ cwd: appContext.appDirectory,
45
+ frameworkConfigPath: appContext.configFile || void 0,
45
46
  bundlerType,
46
47
  config: builderConfig
47
48
  });
@@ -32,21 +32,14 @@ __export(adapterBasic_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(adapterBasic_exports);
34
34
  var import_path = __toESM(require("path"));
35
+ var import_uni_builder = require("@modern-js/uni-builder");
35
36
  const builderPluginAdapterBasic = () => ({
36
37
  name: "builder-plugin-adapter-modern-basic",
37
38
  setup(api) {
38
- api.modifyBundlerChain((chain, { target, CHAIN_ID }) => {
39
- if (target === "node") {
40
- chain.name("server");
41
- } else if (target === "service-worker") {
42
- chain.name("service-worker");
43
- } else if (target === "web-worker") {
44
- chain.name("worker");
45
- } else {
46
- chain.name("client");
47
- }
48
- if (target === "node" || target === "service-worker") {
49
- applyNodeCompat(target, chain);
39
+ api.modifyBundlerChain((chain, { target, CHAIN_ID, environment }) => {
40
+ const isServiceWorker = environment.name === import_uni_builder.SERVICE_WORKER_ENVIRONMENT_NAME;
41
+ if (target === "node" || isServiceWorker) {
42
+ applyNodeCompat(isServiceWorker, chain);
50
43
  }
51
44
  if (target === "web") {
52
45
  const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
@@ -57,7 +50,7 @@ const builderPluginAdapterBasic = () => ({
57
50
  });
58
51
  }
59
52
  });
60
- function applyNodeCompat(target, chain) {
53
+ function applyNodeCompat(isServiceWorker, chain) {
61
54
  const nodeExts = [
62
55
  ".node.js",
63
56
  ".node.jsx",
@@ -77,7 +70,7 @@ function applyNodeCompat(target, chain) {
77
70
  for (const ext of nodeExts) {
78
71
  chain.resolve.extensions.prepend(ext);
79
72
  }
80
- if (target === "service-worker") {
73
+ if (isServiceWorker) {
81
74
  for (const ext of webWorkerExts) {
82
75
  chain.resolve.extensions.prepend(ext);
83
76
  }
@@ -29,15 +29,15 @@ const createVirtualModule = (content) => `data:text/javascript,${content}`;
29
29
  const builderPluginAdapterHtml = (options) => ({
30
30
  name: "builder-plugin-adapter-modern-html",
31
31
  setup(api) {
32
- api.modifyBundlerChain(async (chain, { CHAIN_ID, target, HtmlPlugin: HtmlBundlerPlugin }) => {
33
- const builderConfig = api.getNormalizedConfig();
32
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, target, HtmlPlugin: HtmlBundlerPlugin, environment }) => {
33
+ const builderConfig = environment.config;
34
34
  if (!(0, import_uni_builder.isHtmlDisabled)(builderConfig, target)) {
35
35
  applyBottomHtmlPlugin({
36
- api,
37
36
  options,
38
37
  chain,
39
38
  CHAIN_ID,
40
- HtmlBundlerPlugin
39
+ HtmlBundlerPlugin,
40
+ htmlPaths: environment.htmlPaths
41
41
  });
42
42
  await injectAssetPrefix({
43
43
  chain
@@ -55,9 +55,9 @@ async function injectAssetPrefix({ chain }) {
55
55
  entries[entryName].prepend(createVirtualModule(code));
56
56
  });
57
57
  }
58
- function applyBottomHtmlPlugin({ api, chain, options, CHAIN_ID, HtmlBundlerPlugin }) {
58
+ function applyBottomHtmlPlugin({ chain, options, CHAIN_ID, HtmlBundlerPlugin, htmlPaths }) {
59
59
  const { normalizedConfig: modernConfig, appContext } = options;
60
- for (const entryName of Object.keys(api.context.entry)) {
60
+ for (const entryName of Object.keys(htmlPaths)) {
61
61
  const { source: { mainEntryName } } = modernConfig;
62
62
  const isMainEntry = entryName === (mainEntryName || import_utils.MAIN_ENTRY_NAME);
63
63
  const baseTemplateParams = {
@@ -53,18 +53,16 @@ const builderPluginAdapterSSR = (options) => ({
53
53
  }
54
54
  });
55
55
  });
56
- api.modifyBundlerChain(async (chain, { target, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer }) => {
57
- const builderConfig = api.getNormalizedConfig();
56
+ api.modifyBundlerChain(async (chain, { target, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer, environment }) => {
57
+ const builderConfig = environment.config;
58
58
  const { normalizedConfig: normalizedConfig2 } = options;
59
59
  applyRouterPlugin(chain, "route-plugin", options, HtmlBundlerPlugin);
60
60
  if ((0, import_utils.isUseSSRBundle)(normalizedConfig2)) {
61
61
  await applySSRLoaderEntry(chain, options, isServer);
62
62
  applySSRDataLoader(chain, options);
63
63
  }
64
- if ([
65
- "node",
66
- "service-worker"
67
- ].includes(target)) {
64
+ const isServiceWorker = environment.name === import_uni_builder.SERVICE_WORKER_ENVIRONMENT_NAME;
65
+ if (target === "node" || isServiceWorker) {
68
66
  applyFilterEntriesBySSRConfig({
69
67
  isProd,
70
68
  chain,
@@ -22,6 +22,7 @@ __export(adapterWorker_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(adapterWorker_exports);
24
24
  var import_path = require("path");
25
+ var import_uni_builder = require("@modern-js/uni-builder");
25
26
  const getDistPath = (outputConfig, type) => {
26
27
  const { distPath } = outputConfig;
27
28
  const ret = distPath[type];
@@ -33,10 +34,11 @@ const getDistPath = (outputConfig, type) => {
33
34
  const builderPluginAdapterWorker = () => ({
34
35
  name: "builder-plugin-adapter-worker",
35
36
  setup(api) {
36
- api.modifyBundlerChain(async (chain, { isServiceWorker }) => {
37
- const config = api.getNormalizedConfig();
37
+ api.modifyBundlerChain(async (chain, { environment }) => {
38
+ const { config, name } = environment;
39
+ const isServiceWorker = name === import_uni_builder.SERVICE_WORKER_ENVIRONMENT_NAME;
38
40
  if (isServiceWorker) {
39
- const workerPath = getDistPath(config.output, "worker");
41
+ const workerPath = getDistPath(config.output, "root");
40
42
  const filename = import_path.posix.join(workerPath, `[name].js`);
41
43
  chain.output.filename(filename).chunkFilename(filename).libraryTarget("commonjs2");
42
44
  }
@@ -21,7 +21,6 @@ __export(inspect_exports, {
21
21
  inspect: () => inspect
22
22
  });
23
23
  module.exports = __toCommonJS(inspect_exports);
24
- var import_path = require("path");
25
24
  const inspect = async (api, options) => {
26
25
  const appContext = api.useAppContext();
27
26
  if (!appContext.builder) {
@@ -30,7 +29,7 @@ const inspect = async (api, options) => {
30
29
  return appContext.builder.inspectConfig({
31
30
  env: options.env,
32
31
  verbose: options.verbose,
33
- outputPath: (0, import_path.join)(appContext === null || appContext === void 0 ? void 0 : appContext.builder.context.distPath, options.output),
32
+ outputPath: options.output,
34
33
  writeToDisk: true
35
34
  });
36
35
  };
@@ -39,8 +39,6 @@ function createDefaultConfig(appContext) {
39
39
  server: "bundles",
40
40
  worker: "worker"
41
41
  },
42
- // no need to emit assets for SSR bundles
43
- emitAssets: ({ target }) => target !== "node",
44
42
  cleanDistPath: true,
45
43
  disableNodePolyfill: true,
46
44
  enableInlineRouteManifests: true,
@@ -51,6 +51,7 @@ function transformNormalizedConfig(config) {
51
51
  security: {},
52
52
  _raw: {},
53
53
  experiments: {},
54
+ environments: {},
54
55
  autoLoadPlugins,
55
56
  performance: {
56
57
  removeMomentLocale: true
@@ -71,7 +71,8 @@ const getBundleEntry = async (hookRunners, appContext, config) => {
71
71
  absoluteEntryDir: isDirectory((0, import_utils.ensureAbsolutePath)(appDirectory, entryName)) ? (0, import_utils.ensureAbsolutePath)(appDirectory, entryName) : import_path.default.dirname((0, import_utils.ensureAbsolutePath)(appDirectory, entryName)),
72
72
  isAutoMount,
73
73
  customBootstrap: typeof value === "string" ? false : value.customBootstrap && (0, import_utils.ensureAbsolutePath)(appDirectory, value.customBootstrap),
74
- fileSystemRoutes: import_utils.fs.statSync((0, import_utils.ensureAbsolutePath)(appDirectory, entryName)).isDirectory() ? {} : void 0
74
+ fileSystemRoutes: import_utils.fs.statSync((0, import_utils.ensureAbsolutePath)(appDirectory, entryName)).isDirectory() ? {} : void 0,
75
+ isCustomSourceEntry: true
75
76
  };
76
77
  if (!ifAlreadyExists(defaults, entrypoint)) {
77
78
  defaults.push(entrypoint);
@@ -1,4 +1,6 @@
1
- function createBuilderOptions(target, appContext) {
1
+ import { isProd, isServiceWorker, isSSR, isUseSSRBundle } from "@modern-js/utils";
2
+ import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
3
+ function getBuilderEnvironments(normalizedConfig, appContext) {
2
4
  var entries = {};
3
5
  var _appContext_entrypoints = appContext.entrypoints, entrypoints = _appContext_entrypoints === void 0 ? [] : _appContext_entrypoints, checkedEntries = appContext.checkedEntries;
4
6
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
@@ -38,26 +40,40 @@ function createBuilderOptions(target, appContext) {
38
40
  return entry2.replace("index.jsx", "index.server.jsx");
39
41
  });
40
42
  }
41
- return {
42
- cwd: appContext.appDirectory,
43
- target,
44
- frameworkConfigPath: appContext.configFile || void 0,
45
- entry: function entry2(param) {
46
- var _$target = param.target;
47
- if (_$target === "web") {
48
- return entries;
43
+ var environments = {
44
+ web: {
45
+ output: {
46
+ target: "web"
47
+ },
48
+ source: {
49
+ entry: entries
49
50
  }
50
- if ([
51
- "node",
52
- "web-worker",
53
- "service-worker"
54
- ].includes(_$target)) {
55
- return serverEntries;
56
- }
57
- return entries;
58
51
  }
59
52
  };
53
+ var useNodeTarget = isProd() ? isUseSSRBundle(normalizedConfig) : isSSR(normalizedConfig);
54
+ if (useNodeTarget) {
55
+ environments.node = {
56
+ output: {
57
+ target: "node"
58
+ },
59
+ source: {
60
+ entry: serverEntries
61
+ }
62
+ };
63
+ }
64
+ var useWorkerTarget = isServiceWorker(normalizedConfig);
65
+ if (useWorkerTarget) {
66
+ environments[SERVICE_WORKER_ENVIRONMENT_NAME] = {
67
+ output: {
68
+ target: "web-worker"
69
+ },
70
+ source: {
71
+ entry: serverEntries
72
+ }
73
+ };
74
+ }
75
+ return environments;
60
76
  }
61
77
  export {
62
- createBuilderOptions
78
+ getBuilderEnvironments
63
79
  };
@@ -1,30 +1,30 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
- import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
3
  import { createUniBuilder } from "@modern-js/uni-builder";
4
+ import { mergeRsbuildConfig } from "@rsbuild/core";
6
5
  import { createBuilderProviderConfig } from "./createBuilderProviderConfig";
7
- import { getBuilderTargets } from "./getBuilderTargets";
8
- import { createBuilderOptions } from "./createBuilderOptions";
6
+ import { getBuilderEnvironments } from "./getBuilderEnvironments";
9
7
  function generateBuilder(options, bundlerType) {
10
8
  return _generateBuilder.apply(this, arguments);
11
9
  }
12
10
  function _generateBuilder() {
13
11
  _generateBuilder = _async_to_generator(function(options, bundlerType) {
14
- var normalizedConfig, appContext, builderConfig, target, builderOptions, builder;
12
+ var normalizedConfig, appContext, builderConfig, environments, builder;
15
13
  return _ts_generator(this, function(_state) {
16
14
  switch (_state.label) {
17
15
  case 0:
18
16
  normalizedConfig = options.normalizedConfig, appContext = options.appContext;
19
17
  builderConfig = createBuilderProviderConfig(normalizedConfig, appContext);
20
- target = getBuilderTargets(normalizedConfig);
21
- builderOptions = createBuilderOptions(target, appContext);
18
+ environments = getBuilderEnvironments(normalizedConfig, appContext);
19
+ builderConfig.environments = builderConfig.environments ? mergeRsbuildConfig(environments, builderConfig.environments) : environments;
22
20
  return [
23
21
  4,
24
- createUniBuilder(_object_spread_props(_object_spread({}, builderOptions), {
22
+ createUniBuilder({
23
+ cwd: appContext.appDirectory,
24
+ frameworkConfigPath: appContext.configFile || void 0,
25
25
  bundlerType,
26
26
  config: builderConfig
27
- }))
27
+ })
28
28
  ];
29
29
  case 1:
30
30
  builder = _state.sent();
@@ -1,21 +1,14 @@
1
1
  import path from "path";
2
+ import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
2
3
  var builderPluginAdapterBasic = function() {
3
4
  return {
4
5
  name: "builder-plugin-adapter-modern-basic",
5
6
  setup: function setup(api) {
6
7
  api.modifyBundlerChain(function(chain, param) {
7
- var target = param.target, CHAIN_ID = param.CHAIN_ID;
8
- if (target === "node") {
9
- chain.name("server");
10
- } else if (target === "service-worker") {
11
- chain.name("service-worker");
12
- } else if (target === "web-worker") {
13
- chain.name("worker");
14
- } else {
15
- chain.name("client");
16
- }
17
- if (target === "node" || target === "service-worker") {
18
- applyNodeCompat(target, chain);
8
+ var target = param.target, CHAIN_ID = param.CHAIN_ID, environment = param.environment;
9
+ var isServiceWorker = environment.name === SERVICE_WORKER_ENVIRONMENT_NAME;
10
+ if (target === "node" || isServiceWorker) {
11
+ applyNodeCompat(isServiceWorker, chain);
19
12
  }
20
13
  if (target === "web") {
21
14
  var bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
@@ -27,7 +20,7 @@ var builderPluginAdapterBasic = function() {
27
20
  }
28
21
  };
29
22
  };
30
- function applyNodeCompat(target, chain) {
23
+ function applyNodeCompat(isServiceWorker, chain) {
31
24
  var nodeExts = [
32
25
  ".node.js",
33
26
  ".node.jsx",
@@ -64,7 +57,7 @@ function applyNodeCompat(target, chain) {
64
57
  }
65
58
  }
66
59
  }
67
- if (target === "service-worker") {
60
+ if (isServiceWorker) {
68
61
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
69
62
  try {
70
63
  for (var _iterator1 = webWorkerExts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
@@ -15,23 +15,23 @@ var builderPluginAdapterHtml = function(options) {
15
15
  setup: function setup(api) {
16
16
  api.modifyBundlerChain(function() {
17
17
  var _ref = _async_to_generator(function(chain, param) {
18
- var CHAIN_ID, target, HtmlBundlerPlugin, builderConfig;
18
+ var CHAIN_ID, target, HtmlBundlerPlugin, environment, builderConfig;
19
19
  return _ts_generator(this, function(_state) {
20
20
  switch (_state.label) {
21
21
  case 0:
22
- CHAIN_ID = param.CHAIN_ID, target = param.target, HtmlBundlerPlugin = param.HtmlPlugin;
23
- builderConfig = api.getNormalizedConfig();
22
+ CHAIN_ID = param.CHAIN_ID, target = param.target, HtmlBundlerPlugin = param.HtmlPlugin, environment = param.environment;
23
+ builderConfig = environment.config;
24
24
  if (!!isHtmlDisabled(builderConfig, target))
25
25
  return [
26
26
  3,
27
27
  2
28
28
  ];
29
29
  applyBottomHtmlPlugin({
30
- api,
31
30
  options,
32
31
  chain,
33
32
  CHAIN_ID,
34
- HtmlBundlerPlugin
33
+ HtmlBundlerPlugin,
34
+ htmlPaths: environment.htmlPaths
35
35
  });
36
36
  return [
37
37
  4,
@@ -79,7 +79,7 @@ function _injectAssetPrefix() {
79
79
  return _injectAssetPrefix.apply(this, arguments);
80
80
  }
81
81
  function applyBottomHtmlPlugin(param) {
82
- var api = param.api, chain = param.chain, options = param.options, CHAIN_ID = param.CHAIN_ID, HtmlBundlerPlugin = param.HtmlBundlerPlugin;
82
+ var chain = param.chain, options = param.options, CHAIN_ID = param.CHAIN_ID, HtmlBundlerPlugin = param.HtmlBundlerPlugin, htmlPaths = param.htmlPaths;
83
83
  var modernConfig = options.normalizedConfig, appContext = options.appContext;
84
84
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
85
85
  try {
@@ -101,7 +101,7 @@ function applyBottomHtmlPlugin(param) {
101
101
  ];
102
102
  });
103
103
  };
104
- for (var _iterator = Object.keys(api.context.entry)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)
104
+ for (var _iterator = Object.keys(htmlPaths)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)
105
105
  _loop();
106
106
  } catch (err) {
107
107
  _didIteratorError = true;
@@ -3,7 +3,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import * as path from "path";
4
4
  import { mergeRsbuildConfig } from "@rsbuild/core";
5
5
  import { fs, isUseSSRBundle } from "@modern-js/utils";
6
- import { isHtmlDisabled } from "@modern-js/uni-builder";
6
+ import { isHtmlDisabled, SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
7
7
  import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins";
8
8
  import { getServerCombinedModueFile } from "../../../plugins/analyze/utils";
9
9
  var builderPluginAdapterSSR = function(options) {
@@ -25,12 +25,12 @@ var builderPluginAdapterSSR = function(options) {
25
25
  });
26
26
  api.modifyBundlerChain(function() {
27
27
  var _ref = _async_to_generator(function(chain, param) {
28
- var target, isProd, HtmlBundlerPlugin, isServer, builderConfig, normalizedConfig2;
28
+ var target, isProd, HtmlBundlerPlugin, isServer, environment, builderConfig, normalizedConfig2, isServiceWorker;
29
29
  return _ts_generator(this, function(_state) {
30
30
  switch (_state.label) {
31
31
  case 0:
32
- target = param.target, isProd = param.isProd, HtmlBundlerPlugin = param.HtmlPlugin, isServer = param.isServer;
33
- builderConfig = api.getNormalizedConfig();
32
+ target = param.target, isProd = param.isProd, HtmlBundlerPlugin = param.HtmlPlugin, isServer = param.isServer, environment = param.environment;
33
+ builderConfig = environment.config;
34
34
  normalizedConfig2 = options.normalizedConfig;
35
35
  applyRouterPlugin(chain, "route-plugin", options, HtmlBundlerPlugin);
36
36
  if (!isUseSSRBundle(normalizedConfig2))
@@ -47,10 +47,8 @@ var builderPluginAdapterSSR = function(options) {
47
47
  applySSRDataLoader(chain, options);
48
48
  _state.label = 2;
49
49
  case 2:
50
- if ([
51
- "node",
52
- "service-worker"
53
- ].includes(target)) {
50
+ isServiceWorker = environment.name === SERVICE_WORKER_ENVIRONMENT_NAME;
51
+ if (target === "node" || isServiceWorker) {
54
52
  applyFilterEntriesBySSRConfig({
55
53
  isProd,
56
54
  chain,
@@ -1,6 +1,7 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import { posix } from "path";
4
+ import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
4
5
  var getDistPath = function(outputConfig, type) {
5
6
  var distPath = outputConfig.distPath;
6
7
  var ret = distPath[type];
@@ -15,12 +16,13 @@ var builderPluginAdapterWorker = function() {
15
16
  setup: function setup(api) {
16
17
  api.modifyBundlerChain(function() {
17
18
  var _ref = _async_to_generator(function(chain, param) {
18
- var isServiceWorker, config, workerPath, filename;
19
+ var environment, config, name, isServiceWorker, workerPath, filename;
19
20
  return _ts_generator(this, function(_state) {
20
- isServiceWorker = param.isServiceWorker;
21
- config = api.getNormalizedConfig();
21
+ environment = param.environment;
22
+ config = environment.config, name = environment.name;
23
+ isServiceWorker = name === SERVICE_WORKER_ENVIRONMENT_NAME;
22
24
  if (isServiceWorker) {
23
- workerPath = getDistPath(config.output, "worker");
25
+ workerPath = getDistPath(config.output, "root");
24
26
  filename = posix.join(workerPath, "[name].js");
25
27
  chain.output.filename(filename).chunkFilename(filename).libraryTarget("commonjs2");
26
28
  }
@@ -1,6 +1,5 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import { join } from "path";
4
3
  var inspect = function() {
5
4
  var _ref = _async_to_generator(function(api, options) {
6
5
  var appContext;
@@ -14,7 +13,7 @@ var inspect = function() {
14
13
  appContext.builder.inspectConfig({
15
14
  env: options.env,
16
15
  verbose: options.verbose,
17
- outputPath: join(appContext === null || appContext === void 0 ? void 0 : appContext.builder.context.distPath, options.output),
16
+ outputPath: options.output,
18
17
  writeToDisk: true
19
18
  })
20
19
  ];
@@ -16,11 +16,6 @@ function createDefaultConfig(appContext) {
16
16
  server: "bundles",
17
17
  worker: "worker"
18
18
  },
19
- // no need to emit assets for SSR bundles
20
- emitAssets: function(param) {
21
- var target = param.target;
22
- return target !== "node";
23
- },
24
19
  cleanDistPath: true,
25
20
  disableNodePolyfill: true,
26
21
  enableInlineRouteManifests: true,
@@ -27,6 +27,7 @@ function transformNormalizedConfig(config) {
27
27
  security: {},
28
28
  _raw: {},
29
29
  experiments: {},
30
+ environments: {},
30
31
  autoLoadPlugins,
31
32
  performance: {
32
33
  removeMomentLocale: true
@@ -67,7 +67,8 @@ var getBundleEntry = function() {
67
67
  absoluteEntryDir: isDirectory(ensureAbsolutePath(appDirectory, entryName)) ? ensureAbsolutePath(appDirectory, entryName) : path.dirname(ensureAbsolutePath(appDirectory, entryName)),
68
68
  isAutoMount,
69
69
  customBootstrap: typeof value === "string" ? false : value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
70
- fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, entryName)).isDirectory() ? {} : void 0
70
+ fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, entryName)).isDirectory() ? {} : void 0,
71
+ isCustomSourceEntry: true
71
72
  };
72
73
  if (!ifAlreadyExists(defaults, entrypoint)) {
73
74
  defaults.push(entrypoint);
@@ -0,0 +1,60 @@
1
+ import { isProd, isServiceWorker, isSSR, isUseSSRBundle } from "@modern-js/utils";
2
+ import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
3
+ function getBuilderEnvironments(normalizedConfig, appContext) {
4
+ const entries = {};
5
+ const { entrypoints = [], checkedEntries } = appContext;
6
+ for (const { entryName, internalEntry, entry } of entrypoints) {
7
+ if (checkedEntries && !checkedEntries.includes(entryName)) {
8
+ continue;
9
+ }
10
+ const finalEntry = internalEntry || entry;
11
+ if (entryName in entries) {
12
+ entries[entryName].push(finalEntry);
13
+ } else {
14
+ entries[entryName] = [
15
+ finalEntry
16
+ ];
17
+ }
18
+ }
19
+ const serverEntries = {};
20
+ for (const entry in entries) {
21
+ const v = entries[entry];
22
+ serverEntries[entry] = v.map((entry2) => entry2.replace("index.jsx", "index.server.jsx"));
23
+ }
24
+ const environments = {
25
+ web: {
26
+ output: {
27
+ target: "web"
28
+ },
29
+ source: {
30
+ entry: entries
31
+ }
32
+ }
33
+ };
34
+ const useNodeTarget = isProd() ? isUseSSRBundle(normalizedConfig) : isSSR(normalizedConfig);
35
+ if (useNodeTarget) {
36
+ environments.node = {
37
+ output: {
38
+ target: "node"
39
+ },
40
+ source: {
41
+ entry: serverEntries
42
+ }
43
+ };
44
+ }
45
+ const useWorkerTarget = isServiceWorker(normalizedConfig);
46
+ if (useWorkerTarget) {
47
+ environments[SERVICE_WORKER_ENVIRONMENT_NAME] = {
48
+ output: {
49
+ target: "web-worker"
50
+ },
51
+ source: {
52
+ entry: serverEntries
53
+ }
54
+ };
55
+ }
56
+ return environments;
57
+ }
58
+ export {
59
+ getBuilderEnvironments
60
+ };
@@ -1,14 +1,15 @@
1
1
  import { createUniBuilder } from "@modern-js/uni-builder";
2
+ import { mergeRsbuildConfig } from "@rsbuild/core";
2
3
  import { createBuilderProviderConfig } from "./createBuilderProviderConfig";
3
- import { getBuilderTargets } from "./getBuilderTargets";
4
- import { createBuilderOptions } from "./createBuilderOptions";
4
+ import { getBuilderEnvironments } from "./getBuilderEnvironments";
5
5
  async function generateBuilder(options, bundlerType) {
6
6
  const { normalizedConfig, appContext } = options;
7
7
  const builderConfig = createBuilderProviderConfig(normalizedConfig, appContext);
8
- const target = getBuilderTargets(normalizedConfig);
9
- const builderOptions = createBuilderOptions(target, appContext);
8
+ const environments = getBuilderEnvironments(normalizedConfig, appContext);
9
+ builderConfig.environments = builderConfig.environments ? mergeRsbuildConfig(environments, builderConfig.environments) : environments;
10
10
  const builder = await createUniBuilder({
11
- ...builderOptions,
11
+ cwd: appContext.appDirectory,
12
+ frameworkConfigPath: appContext.configFile || void 0,
12
13
  bundlerType,
13
14
  config: builderConfig
14
15
  });
@@ -1,19 +1,12 @@
1
1
  import path from "path";
2
+ import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
2
3
  const builderPluginAdapterBasic = () => ({
3
4
  name: "builder-plugin-adapter-modern-basic",
4
5
  setup(api) {
5
- api.modifyBundlerChain((chain, { target, CHAIN_ID }) => {
6
- if (target === "node") {
7
- chain.name("server");
8
- } else if (target === "service-worker") {
9
- chain.name("service-worker");
10
- } else if (target === "web-worker") {
11
- chain.name("worker");
12
- } else {
13
- chain.name("client");
14
- }
15
- if (target === "node" || target === "service-worker") {
16
- applyNodeCompat(target, chain);
6
+ api.modifyBundlerChain((chain, { target, CHAIN_ID, environment }) => {
7
+ const isServiceWorker = environment.name === SERVICE_WORKER_ENVIRONMENT_NAME;
8
+ if (target === "node" || isServiceWorker) {
9
+ applyNodeCompat(isServiceWorker, chain);
17
10
  }
18
11
  if (target === "web") {
19
12
  const bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
@@ -24,7 +17,7 @@ const builderPluginAdapterBasic = () => ({
24
17
  });
25
18
  }
26
19
  });
27
- function applyNodeCompat(target, chain) {
20
+ function applyNodeCompat(isServiceWorker, chain) {
28
21
  const nodeExts = [
29
22
  ".node.js",
30
23
  ".node.jsx",
@@ -44,7 +37,7 @@ function applyNodeCompat(target, chain) {
44
37
  for (const ext of nodeExts) {
45
38
  chain.resolve.extensions.prepend(ext);
46
39
  }
47
- if (target === "service-worker") {
40
+ if (isServiceWorker) {
48
41
  for (const ext of webWorkerExts) {
49
42
  chain.resolve.extensions.prepend(ext);
50
43
  }
@@ -6,15 +6,15 @@ const createVirtualModule = (content) => `data:text/javascript,${content}`;
6
6
  const builderPluginAdapterHtml = (options) => ({
7
7
  name: "builder-plugin-adapter-modern-html",
8
8
  setup(api) {
9
- api.modifyBundlerChain(async (chain, { CHAIN_ID, target, HtmlPlugin: HtmlBundlerPlugin }) => {
10
- const builderConfig = api.getNormalizedConfig();
9
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, target, HtmlPlugin: HtmlBundlerPlugin, environment }) => {
10
+ const builderConfig = environment.config;
11
11
  if (!isHtmlDisabled(builderConfig, target)) {
12
12
  applyBottomHtmlPlugin({
13
- api,
14
13
  options,
15
14
  chain,
16
15
  CHAIN_ID,
17
- HtmlBundlerPlugin
16
+ HtmlBundlerPlugin,
17
+ htmlPaths: environment.htmlPaths
18
18
  });
19
19
  await injectAssetPrefix({
20
20
  chain
@@ -32,9 +32,9 @@ async function injectAssetPrefix({ chain }) {
32
32
  entries[entryName].prepend(createVirtualModule(code));
33
33
  });
34
34
  }
35
- function applyBottomHtmlPlugin({ api, chain, options, CHAIN_ID, HtmlBundlerPlugin }) {
35
+ function applyBottomHtmlPlugin({ chain, options, CHAIN_ID, HtmlBundlerPlugin, htmlPaths }) {
36
36
  const { normalizedConfig: modernConfig, appContext } = options;
37
- for (const entryName of Object.keys(api.context.entry)) {
37
+ for (const entryName of Object.keys(htmlPaths)) {
38
38
  const { source: { mainEntryName } } = modernConfig;
39
39
  const isMainEntry = entryName === (mainEntryName || MAIN_ENTRY_NAME);
40
40
  const baseTemplateParams = {
@@ -1,7 +1,7 @@
1
1
  import * as path from "path";
2
2
  import { mergeRsbuildConfig } from "@rsbuild/core";
3
3
  import { fs, isUseSSRBundle } from "@modern-js/utils";
4
- import { isHtmlDisabled } from "@modern-js/uni-builder";
4
+ import { isHtmlDisabled, SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
5
5
  import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins";
6
6
  import { getServerCombinedModueFile } from "../../../plugins/analyze/utils";
7
7
  const builderPluginAdapterSSR = (options) => ({
@@ -20,18 +20,16 @@ const builderPluginAdapterSSR = (options) => ({
20
20
  }
21
21
  });
22
22
  });
23
- api.modifyBundlerChain(async (chain, { target, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer }) => {
24
- const builderConfig = api.getNormalizedConfig();
23
+ api.modifyBundlerChain(async (chain, { target, isProd, HtmlPlugin: HtmlBundlerPlugin, isServer, environment }) => {
24
+ const builderConfig = environment.config;
25
25
  const { normalizedConfig: normalizedConfig2 } = options;
26
26
  applyRouterPlugin(chain, "route-plugin", options, HtmlBundlerPlugin);
27
27
  if (isUseSSRBundle(normalizedConfig2)) {
28
28
  await applySSRLoaderEntry(chain, options, isServer);
29
29
  applySSRDataLoader(chain, options);
30
30
  }
31
- if ([
32
- "node",
33
- "service-worker"
34
- ].includes(target)) {
31
+ const isServiceWorker = environment.name === SERVICE_WORKER_ENVIRONMENT_NAME;
32
+ if (target === "node" || isServiceWorker) {
35
33
  applyFilterEntriesBySSRConfig({
36
34
  isProd,
37
35
  chain,
@@ -1,4 +1,5 @@
1
1
  import { posix } from "path";
2
+ import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/uni-builder";
2
3
  const getDistPath = (outputConfig, type) => {
3
4
  const { distPath } = outputConfig;
4
5
  const ret = distPath[type];
@@ -10,10 +11,11 @@ const getDistPath = (outputConfig, type) => {
10
11
  const builderPluginAdapterWorker = () => ({
11
12
  name: "builder-plugin-adapter-worker",
12
13
  setup(api) {
13
- api.modifyBundlerChain(async (chain, { isServiceWorker }) => {
14
- const config = api.getNormalizedConfig();
14
+ api.modifyBundlerChain(async (chain, { environment }) => {
15
+ const { config, name } = environment;
16
+ const isServiceWorker = name === SERVICE_WORKER_ENVIRONMENT_NAME;
15
17
  if (isServiceWorker) {
16
- const workerPath = getDistPath(config.output, "worker");
18
+ const workerPath = getDistPath(config.output, "root");
17
19
  const filename = posix.join(workerPath, `[name].js`);
18
20
  chain.output.filename(filename).chunkFilename(filename).libraryTarget("commonjs2");
19
21
  }
@@ -1,4 +1,3 @@
1
- import { join } from "path";
2
1
  const inspect = async (api, options) => {
3
2
  const appContext = api.useAppContext();
4
3
  if (!appContext.builder) {
@@ -7,7 +6,7 @@ const inspect = async (api, options) => {
7
6
  return appContext.builder.inspectConfig({
8
7
  env: options.env,
9
8
  verbose: options.verbose,
10
- outputPath: join(appContext === null || appContext === void 0 ? void 0 : appContext.builder.context.distPath, options.output),
9
+ outputPath: options.output,
11
10
  writeToDisk: true
12
11
  });
13
12
  };
@@ -15,8 +15,6 @@ function createDefaultConfig(appContext) {
15
15
  server: "bundles",
16
16
  worker: "worker"
17
17
  },
18
- // no need to emit assets for SSR bundles
19
- emitAssets: ({ target }) => target !== "node",
20
18
  cleanDistPath: true,
21
19
  disableNodePolyfill: true,
22
20
  enableInlineRouteManifests: true,
@@ -27,6 +27,7 @@ function transformNormalizedConfig(config) {
27
27
  security: {},
28
28
  _raw: {},
29
29
  experiments: {},
30
+ environments: {},
30
31
  autoLoadPlugins,
31
32
  performance: {
32
33
  removeMomentLocale: true
@@ -38,7 +38,8 @@ const getBundleEntry = async (hookRunners, appContext, config) => {
38
38
  absoluteEntryDir: isDirectory(ensureAbsolutePath(appDirectory, entryName)) ? ensureAbsolutePath(appDirectory, entryName) : path.dirname(ensureAbsolutePath(appDirectory, entryName)),
39
39
  isAutoMount,
40
40
  customBootstrap: typeof value === "string" ? false : value.customBootstrap && ensureAbsolutePath(appDirectory, value.customBootstrap),
41
- fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, entryName)).isDirectory() ? {} : void 0
41
+ fileSystemRoutes: fs.statSync(ensureAbsolutePath(appDirectory, entryName)).isDirectory() ? {} : void 0,
42
+ isCustomSourceEntry: true
42
43
  };
43
44
  if (!ifAlreadyExists(defaults, entrypoint)) {
44
45
  defaults.push(entrypoint);
@@ -0,0 +1,5 @@
1
+ import type { IAppContext } from '@modern-js/core';
2
+ import type { AppNormalizedConfig } from '../../types';
3
+ export declare function getBuilderEnvironments(normalizedConfig: AppNormalizedConfig<'shared'>, appContext: IAppContext): {
4
+ [name: string]: import("@rsbuild/core/dist-types/types").EnvironmentConfig;
5
+ };
@@ -1,5 +1,6 @@
1
1
  import type { ServerUserConfig, BffUserConfig } from '@modern-js/server-core';
2
2
  import type { UniBuilderPlugin } from '@modern-js/uni-builder';
3
+ import type { RsbuildConfig } from '@rsbuild/core';
3
4
  import type { Bundler } from '../utils';
4
5
  import type { OutputUserConfig } from './output';
5
6
  import type { SourceUserConfig } from './source';
@@ -40,6 +41,7 @@ export interface AppToolsUserConfig<B extends Bundler> {
40
41
  builderPlugins?: UniBuilderPlugin[];
41
42
  performance?: PerformanceUserConfig;
42
43
  devtools?: any;
44
+ environments?: RsbuildConfig['environments'];
43
45
  }
44
46
  interface SharedNormalizedConfig<RawConfig> {
45
47
  cliOptions?: Record<string, any>;
@@ -9,9 +9,15 @@ export type Entry = string | {
9
9
  */
10
10
  disableMount?: boolean;
11
11
  /**
12
+ * @deprecated
13
+ * Using customEntry instead.
12
14
  * Specify the file path of custom bootstrap.
13
15
  */
14
16
  customBootstrap?: string;
17
+ /**
18
+ * use src/{entryName}/entry.tsx to custom entry
19
+ */
20
+ customEntry?: boolean;
15
21
  };
16
22
  export type Entries = Record<string, Entry>;
17
23
  export interface SourceUserConfig extends NonNullable<UniBuilderConfig['source']> {
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.55.0",
18
+ "version": "2.56.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -76,9 +76,9 @@
76
76
  "dependencies": {
77
77
  "@babel/parser": "^7.22.15",
78
78
  "@babel/traverse": "^7.23.2",
79
- "@babel/types": "^7.23.0",
80
- "@rsbuild/plugin-node-polyfill": "0.7.10",
81
- "@rsbuild/core": "0.7.10",
79
+ "@babel/types": "^7.24.7",
80
+ "@rsbuild/plugin-node-polyfill": "1.0.3",
81
+ "@rsbuild/core": "1.0.1-beta.3",
82
82
  "@swc/helpers": "0.5.3",
83
83
  "@vercel/nft": "^0.26.4",
84
84
  "es-module-lexer": "^1.1.0",
@@ -87,23 +87,23 @@
87
87
  "mlly": "^1.6.1",
88
88
  "pkg-types": "^1.1.0",
89
89
  "std-env": "^3.7.0",
90
- "@modern-js/node-bundle-require": "2.55.0",
91
- "@modern-js/core": "2.55.0",
92
- "@modern-js/plugin": "2.55.0",
93
- "@modern-js/plugin-data-loader": "2.55.0",
94
- "@modern-js/plugin-i18n": "2.55.0",
95
- "@modern-js/plugin-lint": "2.55.0",
96
- "@modern-js/prod-server": "2.55.0",
97
- "@modern-js/server-core": "2.55.0",
98
- "@modern-js/server": "2.55.0",
99
- "@modern-js/server-utils": "2.55.0",
100
- "@modern-js/rsbuild-plugin-esbuild": "2.55.0",
101
- "@modern-js/types": "2.55.0",
102
- "@modern-js/utils": "2.55.0",
103
- "@modern-js/uni-builder": "2.55.0"
90
+ "@modern-js/core": "2.56.0",
91
+ "@modern-js/node-bundle-require": "2.56.0",
92
+ "@modern-js/plugin": "2.56.0",
93
+ "@modern-js/plugin-data-loader": "2.56.0",
94
+ "@modern-js/plugin-i18n": "2.56.0",
95
+ "@modern-js/prod-server": "2.56.0",
96
+ "@modern-js/plugin-lint": "2.56.0",
97
+ "@modern-js/rsbuild-plugin-esbuild": "2.56.0",
98
+ "@modern-js/server": "2.56.0",
99
+ "@modern-js/server-core": "2.56.0",
100
+ "@modern-js/server-utils": "2.56.0",
101
+ "@modern-js/uni-builder": "2.56.0",
102
+ "@modern-js/types": "2.56.0",
103
+ "@modern-js/utils": "2.56.0"
104
104
  },
105
105
  "devDependencies": {
106
- "@rsbuild/plugin-swc": "0.7.10",
106
+ "@rsbuild/plugin-swc": "1.0.1-beta.3",
107
107
  "@types/babel__traverse": "7.18.5",
108
108
  "@types/jest": "^29",
109
109
  "@types/node": "^14",
@@ -111,9 +111,9 @@
111
111
  "ts-node": "^10.9.1",
112
112
  "tsconfig-paths": "^4.2.0",
113
113
  "typescript": "^5",
114
- "webpack": "^5.92.0",
115
- "@scripts/build": "2.55.0",
116
- "@scripts/jest-config": "2.55.0"
114
+ "webpack": "^5.93.0",
115
+ "@scripts/build": "2.56.0",
116
+ "@scripts/jest-config": "2.56.0"
117
117
  },
118
118
  "sideEffects": false,
119
119
  "publishConfig": {
@@ -1,42 +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 getBuilderTargets_exports = {};
20
- __export(getBuilderTargets_exports, {
21
- getBuilderTargets: () => getBuilderTargets
22
- });
23
- module.exports = __toCommonJS(getBuilderTargets_exports);
24
- var import_utils = require("@modern-js/utils");
25
- function getBuilderTargets(normalizedConfig) {
26
- const targets = [
27
- "web"
28
- ];
29
- const useNodeTarget = (0, import_utils.isProd)() ? (0, import_utils.isUseSSRBundle)(normalizedConfig) : (0, import_utils.isSSR)(normalizedConfig);
30
- if (useNodeTarget) {
31
- targets.push("node");
32
- }
33
- const useWorkerTarget = (0, import_utils.isServiceWorker)(normalizedConfig);
34
- if (useWorkerTarget) {
35
- targets.push("service-worker");
36
- }
37
- return targets;
38
- }
39
- // Annotate the CommonJS export names for ESM import in node:
40
- 0 && (module.exports = {
41
- getBuilderTargets
42
- });
@@ -1,18 +0,0 @@
1
- import { isProd, isServiceWorker, isSSR, isUseSSRBundle } from "@modern-js/utils";
2
- function getBuilderTargets(normalizedConfig) {
3
- var targets = [
4
- "web"
5
- ];
6
- var useNodeTarget = isProd() ? isUseSSRBundle(normalizedConfig) : isSSR(normalizedConfig);
7
- if (useNodeTarget) {
8
- targets.push("node");
9
- }
10
- var useWorkerTarget = isServiceWorker(normalizedConfig);
11
- if (useWorkerTarget) {
12
- targets.push("service-worker");
13
- }
14
- return targets;
15
- }
16
- export {
17
- getBuilderTargets
18
- };
@@ -1,43 +0,0 @@
1
- function createBuilderOptions(target, appContext) {
2
- const entries = {};
3
- const { entrypoints = [], checkedEntries } = appContext;
4
- for (const { entryName, internalEntry, entry } of entrypoints) {
5
- if (checkedEntries && !checkedEntries.includes(entryName)) {
6
- continue;
7
- }
8
- const finalEntry = internalEntry || entry;
9
- if (entryName in entries) {
10
- entries[entryName].push(finalEntry);
11
- } else {
12
- entries[entryName] = [
13
- finalEntry
14
- ];
15
- }
16
- }
17
- const serverEntries = {};
18
- for (const entry in entries) {
19
- const v = entries[entry];
20
- serverEntries[entry] = v.map((entry2) => entry2.replace("index.jsx", "index.server.jsx"));
21
- }
22
- return {
23
- cwd: appContext.appDirectory,
24
- target,
25
- frameworkConfigPath: appContext.configFile || void 0,
26
- entry({ target: target2 }) {
27
- if (target2 === "web") {
28
- return entries;
29
- }
30
- if ([
31
- "node",
32
- "web-worker",
33
- "service-worker"
34
- ].includes(target2)) {
35
- return serverEntries;
36
- }
37
- return entries;
38
- }
39
- };
40
- }
41
- export {
42
- createBuilderOptions
43
- };
@@ -1,18 +0,0 @@
1
- import { isProd, isServiceWorker, isSSR, isUseSSRBundle } from "@modern-js/utils";
2
- function getBuilderTargets(normalizedConfig) {
3
- const targets = [
4
- "web"
5
- ];
6
- const useNodeTarget = isProd() ? isUseSSRBundle(normalizedConfig) : isSSR(normalizedConfig);
7
- if (useNodeTarget) {
8
- targets.push("node");
9
- }
10
- const useWorkerTarget = isServiceWorker(normalizedConfig);
11
- if (useWorkerTarget) {
12
- targets.push("service-worker");
13
- }
14
- return targets;
15
- }
16
- export {
17
- getBuilderTargets
18
- };
@@ -1,3 +0,0 @@
1
- import type { RsbuildTarget, CreateUniBuilderOptions } from '@modern-js/uni-builder';
2
- import type { IAppContext } from '@modern-js/core';
3
- export declare function createBuilderOptions(target: RsbuildTarget | RsbuildTarget[], appContext: IAppContext): Omit<CreateUniBuilderOptions, 'bundlerType' | 'config'>;
@@ -1,3 +0,0 @@
1
- import type { RsbuildTarget } from '@rsbuild/core';
2
- import type { AppNormalizedConfig } from '../../types';
3
- export declare function getBuilderTargets(normalizedConfig: AppNormalizedConfig<'shared'>): RsbuildTarget[];