@esmx/rspack 3.0.0-rc.78 → 3.0.0-rc.80

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { type RspackAppConfigContext, type RspackAppChainContext, type RspackAppOptions, type BuildTarget, createRspackApp, RSPACK_LOADER } from './rspack';
1
+ export { type BuildTarget, createRspackApp, RSPACK_LOADER, type RspackAppChainContext, type RspackAppConfigContext, type RspackAppOptions } from './rspack';
2
2
  export { createRspackHtmlApp, type RspackHtmlAppOptions } from './rspack-html';
3
3
  import * as rspack from '@rspack/core';
4
4
  export { rspack };
@@ -0,0 +1,5 @@
1
+ import type RspackChain from 'rspack-chain';
2
+ import type { ParsedModuleLinkPluginOptions } from './types';
3
+ export declare function applyEntryConfig(chain: RspackChain, opts: ParsedModuleLinkPluginOptions): void;
4
+ export declare function applyModuleConfig(chain: RspackChain): void;
5
+ export declare function applyExternalsConfig(chain: RspackChain, opts: ParsedModuleLinkPluginOptions): void;
@@ -1,24 +1,4 @@
1
- export function applyChainConfig(chain, opts) {
2
- const isProduction = chain.get("mode") === "production";
3
- chain.output.set("module", true).set("chunkFormat", "module").set("chunkLoading", "import").set("workerChunkLoading", "import");
4
- chain.experiments({
5
- ...chain.get("experiments"),
6
- outputModule: true
7
- });
8
- if (isProduction) {
9
- chain.output.library({
10
- type: "modern-module"
11
- });
12
- chain.optimization.set("avoidEntryIife", true);
13
- } else {
14
- chain.output.library({
15
- type: "module"
16
- });
17
- }
18
- applyEntryConfig(chain, opts);
19
- applyExternalsConfig(chain, opts);
20
- }
21
- function applyEntryConfig(chain, opts) {
1
+ export function applyEntryConfig(chain, opts) {
22
2
  if (chain.entryPoints.has("main")) {
23
3
  const mainEntry = chain.entry("main");
24
4
  if (mainEntry.values().length === 0) {
@@ -35,7 +15,13 @@ function applyEntryConfig(chain, opts) {
35
15
  }
36
16
  }
37
17
  }
38
- function applyExternalsConfig(chain, opts) {
18
+ export function applyModuleConfig(chain) {
19
+ chain.output.set("module", true).set("chunkFormat", "module").set("chunkLoading", "import").set("workerChunkLoading", "import");
20
+ chain.output.library({
21
+ type: "module"
22
+ });
23
+ }
24
+ export function applyExternalsConfig(chain, opts) {
39
25
  const existingExternals = chain.get("externals") || [];
40
26
  const externals = Array.isArray(existingExternals) ? [...existingExternals] : [existingExternals];
41
27
  const compilerContext = chain.get("context") ?? process.cwd();
@@ -1,3 +1,3 @@
1
1
  import type RspackChain from 'rspack-chain';
2
2
  import type { ParsedModuleLinkPluginOptions } from './types';
3
- export declare function applyChainConfig(chain: RspackChain, opts: ParsedModuleLinkPluginOptions): void;
3
+ export declare function applyChainConfig1(chain: RspackChain, opts: ParsedModuleLinkPluginOptions): void;
@@ -0,0 +1,16 @@
1
+ import {
2
+ applyEntryConfig,
3
+ applyExternalsConfig,
4
+ applyModuleConfig
5
+ } from "./config.mjs";
6
+ export function applyChainConfig1(chain, opts) {
7
+ applyEntryConfig(chain, opts);
8
+ applyExternalsConfig(chain, opts);
9
+ applyModuleConfig(chain);
10
+ if (chain.get("mode") === "production") {
11
+ chain.output.library({
12
+ type: "modern-module"
13
+ });
14
+ chain.optimization.set("avoidEntryIife", true);
15
+ }
16
+ }
@@ -0,0 +1,3 @@
1
+ import type RspackChain from 'rspack-chain';
2
+ import type { ParsedModuleLinkPluginOptions } from './types';
3
+ export declare function applyChainConfig2(chain: RspackChain, opts: ParsedModuleLinkPluginOptions): void;
@@ -0,0 +1,17 @@
1
+ import { rspack } from "@rspack/core";
2
+ import {
3
+ applyEntryConfig,
4
+ applyExternalsConfig,
5
+ applyModuleConfig
6
+ } from "./config.mjs";
7
+ export function applyChainConfig2(chain, opts) {
8
+ applyEntryConfig(chain, opts);
9
+ applyExternalsConfig(chain, opts);
10
+ if (chain.get("mode") === "production") {
11
+ chain.output.set("module", true);
12
+ chain.plugin("esm-library").use(new rspack.experiments.EsmLibraryPlugin());
13
+ chain.optimization.set("runtimeChunk", "single");
14
+ } else {
15
+ applyModuleConfig(chain);
16
+ }
17
+ }
@@ -1,8 +1,8 @@
1
- import { applyChainConfig } from "./apply-chain-config.mjs";
1
+ import { applyChainConfig2 } from "./config2.mjs";
2
2
  import { ManifestPlugin } from "./manifest-plugin.mjs";
3
3
  import { parseOptions } from "./parse.mjs";
4
4
  export function initModuleLink(chain, options) {
5
5
  const opts = parseOptions(options);
6
- applyChainConfig(chain, opts);
6
+ applyChainConfig2(chain, opts);
7
7
  chain.plugin("module-link-manifest").use(ManifestPlugin, [opts]);
8
8
  }
@@ -79,7 +79,7 @@ export function getExports(opts, stats) {
79
79
  const exports = {};
80
80
  for (const [key, value] of Object.entries(entrypoints)) {
81
81
  const asset = value.assets?.find((item) => {
82
- return item.name.endsWith(opts.ext) && !item.name.includes("hot-update");
82
+ return item.name.endsWith(opts.ext) && item.name.startsWith(key) && !item.name.includes("hot-update");
83
83
  });
84
84
  if (!asset) continue;
85
85
  if (key in opts.exports) {
@@ -1,5 +1,5 @@
1
1
  import type { ManifestJsonExports } from '@esmx/core';
2
- export type { ManifestJson, ManifestJsonChunks, ManifestJsonChunk, ManifestJsonExport, ManifestJsonExports } from '@esmx/core';
2
+ export type { ManifestJson, ManifestJsonChunk, ManifestJsonChunks, ManifestJsonExport, ManifestJsonExports } from '@esmx/core';
3
3
  export interface ModuleLinkPluginOptions {
4
4
  name: string;
5
5
  ext?: string;
@@ -1,8 +1,8 @@
1
1
  import { pathToFileURL } from "node:url";
2
2
  import {
3
- RenderContext,
4
3
  createApp,
5
- mergeMiddlewares
4
+ mergeMiddlewares,
5
+ RenderContext
6
6
  } from "@esmx/core";
7
7
  import { createVmImport } from "@esmx/import";
8
8
  import hotMiddleware from "webpack-hot-middleware";
@@ -7,70 +7,74 @@ export function createChainConfig(esmx, buildTarget, options) {
7
7
  const isClient = buildTarget === "client";
8
8
  const isServer = buildTarget === "server";
9
9
  const isNode = buildTarget === "node";
10
- const config = new RspackChain();
11
- config.context(esmx.root);
12
- config.mode(esmx.isProd ? "production" : "development");
13
- config.target(isClient ? "web" : "node24");
14
- config.cache(!esmx.isProd);
15
- config.output.clean(esmx.isProd).filename(
10
+ const chain = new RspackChain();
11
+ chain.context(esmx.root);
12
+ chain.mode(esmx.isProd ? "production" : "development");
13
+ chain.target(isClient ? "web" : "node24");
14
+ chain.cache(!esmx.isProd);
15
+ chain.output.clean(esmx.isProd).filename(
16
16
  !isNode && esmx.isProd ? "[name].[contenthash:8].final.mjs" : "[name].mjs"
17
17
  ).chunkFilename(
18
18
  esmx.isProd ? "chunks/[name].[contenthash:8].final.mjs" : "chunks/[name].mjs"
19
19
  ).publicPath(
20
20
  isClient ? "auto" : `${esmx.basePathPlaceholder}${esmx.basePath}`
21
21
  );
22
- config.output.set(
22
+ chain.output.set(
23
23
  "cssFilename",
24
24
  esmx.isProd ? "[name].[contenthash:8].final.css" : "[name].css"
25
25
  );
26
- config.output.set(
26
+ chain.output.set(
27
27
  "cssChunkFilename",
28
28
  esmx.isProd ? "chunks/[name].[contenthash:8].final.css" : "chunks/[name].css"
29
29
  );
30
- config.output.path(esmx.resolvePath("dist", buildTarget));
31
- config.plugin("progress").use(rspack.ProgressPlugin, [
30
+ chain.output.path(esmx.resolvePath("dist", buildTarget));
31
+ chain.plugin("progress").use(rspack.ProgressPlugin, [
32
32
  {
33
33
  prefix: buildTarget
34
34
  }
35
35
  ]);
36
36
  if (isHot) {
37
- config.plugin("hmr").use(rspack.HotModuleReplacementPlugin);
37
+ chain.plugin("hmr").use(rspack.HotModuleReplacementPlugin);
38
38
  }
39
- config.module.parser.set("javascript", {
39
+ chain.module.parser.set("javascript", {
40
40
  url: isClient ? true : "relative",
41
41
  importMeta: false,
42
42
  strictExportPresence: true
43
43
  });
44
- config.module.generator.set("asset", {
44
+ chain.module.generator.set("asset", {
45
45
  emit: isClient
46
46
  });
47
- config.module.generator.set("asset/resource", {
47
+ chain.module.generator.set("asset/resource", {
48
48
  emit: isClient
49
49
  });
50
- config.resolve.alias.set(esmx.name, esmx.root);
51
- config.optimization.minimize(options.minimize ?? esmx.isProd).emitOnErrors(true);
52
- config.externalsPresets({
50
+ chain.resolve.alias.set(esmx.name, esmx.root);
51
+ chain.optimization.minimize(options.minimize ?? esmx.isProd).emitOnErrors(true);
52
+ chain.externalsPresets({
53
53
  web: isClient,
54
54
  node: isServer || isNode
55
55
  });
56
- config.externalsType("module-import");
56
+ chain.experiments({
57
+ ...chain.get("experiments"),
58
+ outputModule: true
59
+ });
60
+ chain.externalsType("module-import");
57
61
  if (isNode) {
58
- config.externals([
59
- // @ts-ignore
62
+ chain.externals([
63
+ // @ts-expect-error
60
64
  nodeExternals({
61
- // @ts-ignore
65
+ // @ts-expect-error
62
66
  importType: "module-import"
63
67
  })
64
68
  ]);
65
69
  }
66
- config.experiments({
70
+ chain.experiments({
67
71
  nativeWatcher: true,
68
72
  rspackFuture: {
69
73
  bundlerInfo: { force: false }
70
74
  }
71
75
  });
72
- initModuleLink(config, createModuleLinkConfig(esmx, buildTarget));
73
- return config;
76
+ initModuleLink(chain, createModuleLinkConfig(esmx, buildTarget));
77
+ return chain;
74
78
  }
75
79
  function createModuleLinkConfig(esmx, buildTarget) {
76
80
  const isClient = buildTarget === "client";
@@ -1,3 +1,3 @@
1
- export { type RspackAppConfigContext, type RspackAppChainContext, type RspackAppOptions, createRspackApp } from './app';
1
+ export { createRspackApp, type RspackAppChainContext, type RspackAppConfigContext, type RspackAppOptions } from './app';
2
2
  export type { BuildTarget } from './build-target';
3
3
  export { RSPACK_LOADER } from './loader';
@@ -3,8 +3,8 @@ import {
3
3
  } from "@rspack/core";
4
4
  import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
5
5
  import {
6
- RSPACK_LOADER,
7
- createRspackApp
6
+ createRspackApp,
7
+ RSPACK_LOADER
8
8
  } from "../rspack/index.mjs";
9
9
  import { getTargetSetting } from "./target-setting.mjs";
10
10
  export async function createRspackHtmlApp(esmx, options) {
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { PRESET_TARGETS, getTargetSetting } from "./target-setting.mjs";
2
+ import { getTargetSetting, PRESET_TARGETS } from "./target-setting.mjs";
3
3
  describe("getTargetSetting", () => {
4
4
  const buildTargets = ["client", "server", "node"];
5
5
  describe("when setting is undefined", () => {
package/package.json CHANGED
@@ -63,9 +63,9 @@
63
63
  }
64
64
  },
65
65
  "dependencies": {
66
- "@esmx/import": "3.0.0-rc.78",
66
+ "@esmx/import": "3.0.0-rc.80",
67
67
  "@npmcli/arborist": "^9.1.6",
68
- "@rspack/core": "1.6.5",
68
+ "@rspack/core": "^1.6.6",
69
69
  "css-loader": "^7.1.2",
70
70
  "less-loader": "^12.3.0",
71
71
  "node-polyfill-webpack-plugin": "^4.1.0",
@@ -79,9 +79,9 @@
79
79
  "worker-rspack-loader": "^3.1.2"
80
80
  },
81
81
  "devDependencies": {
82
- "@biomejs/biome": "2.3.4",
83
- "@esmx/core": "3.0.0-rc.78",
84
- "@types/node": "^24.10.0",
82
+ "@biomejs/biome": "2.3.7",
83
+ "@esmx/core": "3.0.0-rc.80",
84
+ "@types/node": "^24.0.0",
85
85
  "@types/npmcli__arborist": "^6.3.1",
86
86
  "@types/pacote": "^11.1.8",
87
87
  "@types/webpack-hot-middleware": "^2.25.12",
@@ -91,7 +91,7 @@
91
91
  "unbuild": "3.6.1",
92
92
  "vitest": "3.2.4"
93
93
  },
94
- "version": "3.0.0-rc.78",
94
+ "version": "3.0.0-rc.80",
95
95
  "type": "module",
96
96
  "private": false,
97
97
  "exports": {
@@ -110,5 +110,5 @@
110
110
  "template",
111
111
  "public"
112
112
  ],
113
- "gitHead": "aa44e33ab3e05817977c0fda6148abff8351651f"
113
+ "gitHead": "3fca699d5b4daa50c2c53f4adea0e8a71e14765b"
114
114
  }
package/src/index.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export {
2
- type RspackAppConfigContext,
3
- type RspackAppChainContext,
4
- type RspackAppOptions,
5
2
  type BuildTarget,
6
3
  createRspackApp,
7
- RSPACK_LOADER
4
+ RSPACK_LOADER,
5
+ type RspackAppChainContext,
6
+ type RspackAppConfigContext,
7
+ type RspackAppOptions
8
8
  } from './rspack';
9
9
  export { createRspackHtmlApp, type RspackHtmlAppOptions } from './rspack-html';
10
10
 
@@ -2,44 +2,7 @@ import type { ExternalItem, ExternalItemFunctionData } from '@rspack/core';
2
2
  import type RspackChain from 'rspack-chain';
3
3
  import type { ParsedModuleLinkPluginOptions } from './types';
4
4
 
5
- type ResolvePath = (
6
- request: string,
7
- context?: string
8
- ) => Promise<string | null>;
9
-
10
- export function applyChainConfig(
11
- chain: RspackChain,
12
- opts: ParsedModuleLinkPluginOptions
13
- ): void {
14
- const isProduction = chain.get('mode') === 'production';
15
-
16
- chain.output
17
- .set('module', true)
18
- .set('chunkFormat', 'module')
19
- .set('chunkLoading', 'import')
20
- .set('workerChunkLoading', 'import');
21
- chain.experiments({
22
- ...chain.get('experiments'),
23
- outputModule: true
24
- });
25
-
26
- if (isProduction) {
27
- chain.output.library({
28
- type: 'modern-module'
29
- });
30
- chain.optimization.set('avoidEntryIife', true);
31
- } else {
32
- chain.output.library({
33
- type: 'module'
34
- });
35
- }
36
-
37
- applyEntryConfig(chain, opts);
38
-
39
- applyExternalsConfig(chain, opts);
40
- }
41
-
42
- function applyEntryConfig(
5
+ export function applyEntryConfig(
43
6
  chain: RspackChain,
44
7
  opts: ParsedModuleLinkPluginOptions
45
8
  ): void {
@@ -61,7 +24,18 @@ function applyEntryConfig(
61
24
  }
62
25
  }
63
26
 
64
- function applyExternalsConfig(
27
+ export function applyModuleConfig(chain: RspackChain) {
28
+ chain.output
29
+ .set('module', true)
30
+ .set('chunkFormat', 'module')
31
+ .set('chunkLoading', 'import')
32
+ .set('workerChunkLoading', 'import');
33
+ chain.output.library({
34
+ type: 'module'
35
+ });
36
+ }
37
+
38
+ export function applyExternalsConfig(
65
39
  chain: RspackChain,
66
40
  opts: ParsedModuleLinkPluginOptions
67
41
  ): void {
@@ -83,7 +57,10 @@ function createExternalsFunction(
83
57
  ) {
84
58
  const importMap = new Map<string, string>();
85
59
  let initPromise: Promise<void> | null = null;
86
-
60
+ type ResolvePath = (
61
+ request: string,
62
+ context?: string
63
+ ) => Promise<string | null>;
87
64
  const init = (resolvePath: ResolvePath): Promise<void> => {
88
65
  if (initPromise) return initPromise;
89
66
 
@@ -0,0 +1,24 @@
1
+ import type RspackChain from 'rspack-chain';
2
+ import {
3
+ applyEntryConfig,
4
+ applyExternalsConfig,
5
+ applyModuleConfig
6
+ } from './config';
7
+ import type { ParsedModuleLinkPluginOptions } from './types';
8
+
9
+ export function applyChainConfig1(
10
+ chain: RspackChain,
11
+ opts: ParsedModuleLinkPluginOptions
12
+ ): void {
13
+ applyEntryConfig(chain, opts);
14
+ applyExternalsConfig(chain, opts);
15
+
16
+ // Set module compilation configuration
17
+ applyModuleConfig(chain);
18
+ if (chain.get('mode') === 'production') {
19
+ chain.output.library({
20
+ type: 'modern-module'
21
+ });
22
+ chain.optimization.set('avoidEntryIife', true);
23
+ }
24
+ }
@@ -0,0 +1,28 @@
1
+ import { rspack } from '@rspack/core';
2
+ import type RspackChain from 'rspack-chain';
3
+ import {
4
+ applyEntryConfig,
5
+ applyExternalsConfig,
6
+ applyModuleConfig
7
+ } from './config';
8
+ import type { ParsedModuleLinkPluginOptions } from './types';
9
+
10
+ export function applyChainConfig2(
11
+ chain: RspackChain,
12
+ opts: ParsedModuleLinkPluginOptions
13
+ ): void {
14
+ applyEntryConfig(chain, opts);
15
+ applyExternalsConfig(chain, opts);
16
+
17
+ // Set module compilation configuration
18
+ if (chain.get('mode') === 'production') {
19
+ chain.output.set('module', true);
20
+
21
+ chain
22
+ .plugin('esm-library')
23
+ .use(new rspack.experiments.EsmLibraryPlugin());
24
+ chain.optimization.set('runtimeChunk', 'single');
25
+ } else {
26
+ applyModuleConfig(chain);
27
+ }
28
+ }
@@ -1,5 +1,6 @@
1
1
  import type RspackChain from 'rspack-chain';
2
- import { applyChainConfig } from './apply-chain-config';
2
+ // import { applyChainConfig1 } from './config1';
3
+ import { applyChainConfig2 } from './config2';
3
4
  import { ManifestPlugin } from './manifest-plugin';
4
5
  import { parseOptions } from './parse';
5
6
  import type { ModuleLinkPluginOptions } from './types';
@@ -9,8 +10,8 @@ export function initModuleLink(
9
10
  options: ModuleLinkPluginOptions
10
11
  ): void {
11
12
  const opts = parseOptions(options);
12
-
13
- applyChainConfig(chain, opts);
13
+ // applyChainConfig1(chain, opts);
14
+ applyChainConfig2(chain, opts);
14
15
 
15
16
  chain.plugin('module-link-manifest').use(ManifestPlugin, [opts]);
16
17
  }
@@ -96,11 +96,11 @@ export function getExports(
96
96
  ): ManifestJsonExports {
97
97
  const entrypoints = stats.entrypoints || {};
98
98
  const exports: ManifestJsonExports = {};
99
-
100
99
  for (const [key, value] of Object.entries(entrypoints)) {
101
100
  const asset = value.assets?.find((item) => {
102
101
  return (
103
102
  item.name.endsWith(opts.ext) &&
103
+ item.name.startsWith(key) &&
104
104
  !item.name.includes('hot-update')
105
105
  );
106
106
  });
@@ -165,7 +165,11 @@ export function generateIdentifier({
165
165
  root,
166
166
  name,
167
167
  filePath
168
- }: { root: string; name: string; filePath: string }) {
168
+ }: {
169
+ root: string;
170
+ name: string;
171
+ filePath: string;
172
+ }) {
169
173
  const unixFilePath = upath.toUnix(filePath);
170
174
  if (!root) {
171
175
  return `${name}@${unixFilePath}`;
@@ -2,8 +2,8 @@ import type { ManifestJsonExports } from '@esmx/core';
2
2
 
3
3
  export type {
4
4
  ManifestJson,
5
- ManifestJsonChunks,
6
5
  ManifestJsonChunk,
6
+ ManifestJsonChunks,
7
7
  ManifestJsonExport,
8
8
  ManifestJsonExports
9
9
  } from '@esmx/core';
package/src/rspack/app.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { pathToFileURL } from 'node:url';
2
2
  import {
3
3
  type App,
4
+ createApp,
4
5
  type Esmx,
5
6
  type Middleware,
7
+ mergeMiddlewares,
6
8
  RenderContext,
7
9
  type RenderContextOptions,
8
- type ServerRenderHandle,
9
- createApp,
10
- mergeMiddlewares
10
+ type ServerRenderHandle
11
11
  } from '@esmx/core';
12
12
  import { createVmImport } from '@esmx/import';
13
13
  import type { RspackOptions } from '@rspack/core';
@@ -239,14 +239,14 @@ async function createMiddleware(
239
239
  ]);
240
240
  rsBuild.watch();
241
241
 
242
- // @ts-ignore
242
+ // @ts-expect-error
243
243
  const hot = hotMiddleware(rsBuild.compilers[0], {
244
244
  path: `${esmx.basePath}hot-middleware`
245
245
  });
246
246
  return [
247
247
  (req, res, next) => {
248
248
  if (req.url?.startsWith(`${esmx.basePath}hot-middleware`)) {
249
- // @ts-ignore
249
+ // @ts-expect-error
250
250
  return hot(req, res, next);
251
251
  }
252
252
  return next();
@@ -1,6 +1,6 @@
1
1
  import type { Esmx } from '@esmx/core';
2
- import { rspack } from '@rspack/core';
3
2
  import type { RspackOptions } from '@rspack/core';
3
+ import { rspack } from '@rspack/core';
4
4
  import RspackChain from 'rspack-chain';
5
5
  import nodeExternals from 'webpack-node-externals';
6
6
  import type { ModuleLinkPluginOptions } from '../module-link';
@@ -18,14 +18,14 @@ export function createChainConfig(
18
18
  const isServer = buildTarget === 'server';
19
19
  const isNode = buildTarget === 'node';
20
20
 
21
- const config = new RspackChain();
21
+ const chain = new RspackChain();
22
22
 
23
- config.context(esmx.root);
24
- config.mode(esmx.isProd ? 'production' : 'development');
25
- config.target(isClient ? 'web' : 'node24');
26
- config.cache(!esmx.isProd);
23
+ chain.context(esmx.root);
24
+ chain.mode(esmx.isProd ? 'production' : 'development');
25
+ chain.target(isClient ? 'web' : 'node24');
26
+ chain.cache(!esmx.isProd);
27
27
 
28
- config.output
28
+ chain.output
29
29
  .clean(esmx.isProd)
30
30
  .filename(
31
31
  !isNode && esmx.isProd
@@ -41,73 +41,78 @@ export function createChainConfig(
41
41
  isClient ? 'auto' : `${esmx.basePathPlaceholder}${esmx.basePath}`
42
42
  );
43
43
 
44
- config.output.set(
44
+ chain.output.set(
45
45
  'cssFilename',
46
46
  esmx.isProd ? '[name].[contenthash:8].final.css' : '[name].css'
47
47
  );
48
- config.output.set(
48
+ chain.output.set(
49
49
  'cssChunkFilename',
50
50
  esmx.isProd
51
51
  ? 'chunks/[name].[contenthash:8].final.css'
52
52
  : 'chunks/[name].css'
53
53
  );
54
- config.output.path(esmx.resolvePath('dist', buildTarget));
54
+ chain.output.path(esmx.resolvePath('dist', buildTarget));
55
55
 
56
- config.plugin('progress').use(rspack.ProgressPlugin, [
56
+ chain.plugin('progress').use(rspack.ProgressPlugin, [
57
57
  {
58
58
  prefix: buildTarget
59
59
  }
60
60
  ]);
61
61
 
62
62
  if (isHot) {
63
- config.plugin('hmr').use(rspack.HotModuleReplacementPlugin);
63
+ chain.plugin('hmr').use(rspack.HotModuleReplacementPlugin);
64
64
  }
65
65
 
66
- config.module.parser.set('javascript', {
66
+ chain.module.parser.set('javascript', {
67
67
  url: isClient ? true : 'relative',
68
68
  importMeta: false,
69
69
  strictExportPresence: true
70
70
  });
71
71
 
72
- config.module.generator.set('asset', {
72
+ chain.module.generator.set('asset', {
73
73
  emit: isClient
74
74
  });
75
75
 
76
- config.module.generator.set('asset/resource', {
76
+ chain.module.generator.set('asset/resource', {
77
77
  emit: isClient
78
78
  });
79
79
 
80
- config.resolve.alias.set(esmx.name, esmx.root);
80
+ chain.resolve.alias.set(esmx.name, esmx.root);
81
81
 
82
- config.optimization
82
+ chain.optimization
83
83
  .minimize(options.minimize ?? esmx.isProd)
84
84
  .emitOnErrors(true);
85
85
 
86
- config.externalsPresets({
86
+ chain.externalsPresets({
87
87
  web: isClient,
88
88
  node: isServer || isNode
89
89
  });
90
- config.externalsType('module-import');
90
+
91
+ chain.experiments({
92
+ ...chain.get('experiments'),
93
+ outputModule: true
94
+ });
95
+ chain.externalsType('module-import');
91
96
 
92
97
  if (isNode) {
93
- config.externals([
94
- // @ts-ignore
98
+ chain.externals([
99
+ // @ts-expect-error
95
100
  nodeExternals({
96
- // @ts-ignore
101
+ // @ts-expect-error
97
102
  importType: 'module-import'
98
103
  })
99
104
  ]);
100
105
  }
101
- config.experiments({
106
+ chain.experiments({
102
107
  nativeWatcher: true,
103
108
  rspackFuture: {
104
109
  bundlerInfo: { force: false }
105
110
  }
106
111
  });
107
112
 
108
- initModuleLink(config, createModuleLinkConfig(esmx, buildTarget));
113
+ initModuleLink(chain, createModuleLinkConfig(esmx, buildTarget));
109
114
 
110
- return config;
115
+ return chain;
111
116
  }
112
117
 
113
118
  function createModuleLinkConfig(
@@ -1,8 +1,8 @@
1
1
  export {
2
- type RspackAppConfigContext,
2
+ createRspackApp,
3
3
  type RspackAppChainContext,
4
- type RspackAppOptions,
5
- createRspackApp
4
+ type RspackAppConfigContext,
5
+ type RspackAppOptions
6
6
  } from './app';
7
7
  export type { BuildTarget } from './build-target';
8
8
  export { RSPACK_LOADER } from './loader';
@@ -1,19 +1,19 @@
1
1
  import type { Esmx } from '@esmx/core';
2
2
  import {
3
3
  type LightningcssLoaderOptions,
4
- type SwcLoaderOptions,
5
- rspack
4
+ rspack,
5
+ type SwcLoaderOptions
6
6
  } from '@rspack/core';
7
7
  import NodePolyfillPlugin from 'node-polyfill-webpack-plugin';
8
8
  import type RspackChain from 'rspack-chain';
9
9
  import {
10
10
  type BuildTarget,
11
+ createRspackApp,
11
12
  RSPACK_LOADER,
12
- type RspackAppOptions,
13
- createRspackApp
13
+ type RspackAppOptions
14
14
  } from '../rspack';
15
- import { getTargetSetting } from './target-setting';
16
15
  import type { TargetSetting } from './target-setting';
16
+ import { getTargetSetting } from './target-setting';
17
17
 
18
18
  export type { TargetSetting };
19
19
  export interface RspackHtmlAppOptions extends RspackAppOptions {
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import type { BuildTarget } from '../rspack';
3
- import { PRESET_TARGETS, getTargetSetting } from './target-setting';
4
3
  import type { TargetSetting } from './target-setting';
4
+ import { getTargetSetting, PRESET_TARGETS } from './target-setting';
5
5
 
6
6
  describe('getTargetSetting', () => {
7
7
  const buildTargets: BuildTarget[] = ['client', 'server', 'node'];