@rsbuild/webpack 0.2.3 → 0.2.4

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.
@@ -1,6 +1,6 @@
1
1
  import { InitConfigsOptions } from './initConfigs';
2
2
  import { type Stats, type BuildOptions } from '@rsbuild/shared';
3
- import type { MultiStats, Compiler, MultiCompiler } from 'webpack';
3
+ import type { Compiler, MultiStats, MultiCompiler } from 'webpack';
4
4
  export interface BuildExecuter {
5
5
  (compiler: Compiler): Promise<{
6
6
  stats: Stats;
@@ -1,15 +1,15 @@
1
+ import { type Rspack } from '@rsbuild/shared';
1
2
  import type { Context } from '@rsbuild/core/provider';
2
3
  import type { WebpackConfig } from '../types';
3
4
  import { InitConfigsOptions } from './initConfigs';
4
- import type { Compiler, MultiCompiler } from 'webpack';
5
5
  export declare function createCompiler({
6
6
  context,
7
7
  webpackConfigs
8
8
  }: {
9
9
  context: Context;
10
10
  webpackConfigs: WebpackConfig[];
11
- }): Promise<Compiler | MultiCompiler>;
12
- export declare function createDevMiddleware(options: InitConfigsOptions, customCompiler?: Compiler | MultiCompiler): Promise<{
11
+ }): Promise<Rspack.Compiler | Rspack.MultiCompiler>;
12
+ export declare function createDevMiddleware(options: InitConfigsOptions, customCompiler?: Rspack.Compiler | Rspack.MultiCompiler): Promise<{
13
13
  devMiddleware: import("@rsbuild/shared").DevMiddleware;
14
- compiler: Compiler | MultiCompiler;
14
+ compiler: Rspack.Compiler | Rspack.MultiCompiler;
15
15
  }>;
@@ -84,9 +84,10 @@ async function applyBaseCSSRule({
84
84
  }
85
85
  rule.use(CHAIN_ID.USE.CSS).loader((0, import_shared.getSharedPkgCompiledPath)("css-loader")).options(cssLoaderOptions).end();
86
86
  if (!isServer && !isWebWorker) {
87
- const postcssLoaderOptions = (0, import_shared.getPostcssConfig)({
87
+ const postcssLoaderOptions = await (0, import_shared.getPostcssLoaderOptions)({
88
88
  browserslist,
89
- config
89
+ config,
90
+ root: context.rootPath
90
91
  });
91
92
  rule.use(CHAIN_ID.USE.POSTCSS).loader((0, import_shared.getSharedPkgCompiledPath)("postcss-loader")).options(postcssLoaderOptions).end();
92
93
  }
@@ -1,6 +1,2 @@
1
- import { type RsbuildConfig, type RsbuildProvider } from '@rsbuild/shared';
2
- export declare function webpackProvider({
3
- rsbuildConfig: originalRsbuildConfig
4
- }: {
5
- rsbuildConfig: RsbuildConfig;
6
- }): RsbuildProvider;
1
+ import { type RsbuildProvider } from '@rsbuild/shared';
2
+ export declare const webpackProvider: RsbuildProvider<'webpack'>;
package/dist/provider.js CHANGED
@@ -35,99 +35,93 @@ var import_shared = require("@rsbuild/shared");
35
35
  var import_provider = require("@rsbuild/core/provider");
36
36
  var import_shared2 = require("./shared");
37
37
  var import_initConfigs = require("./core/initConfigs");
38
- function webpackProvider({
39
- rsbuildConfig: originalRsbuildConfig
40
- }) {
41
- const rsbuildConfig = (0, import_shared.pickRsbuildConfig)(originalRsbuildConfig);
42
- return async ({ pluginStore, rsbuildOptions, plugins }) => {
43
- const context = await (0, import_provider.createContext)(
44
- rsbuildOptions,
45
- rsbuildConfig,
46
- "webpack"
47
- );
48
- const pluginAPI = (0, import_provider.getPluginAPI)({ context, pluginStore });
49
- context.pluginAPI = pluginAPI;
50
- return {
51
- bundler: "webpack",
52
- pluginAPI,
53
- publicContext: (0, import_provider.createPublicContext)(context),
54
- async applyDefaultPlugins() {
55
- pluginStore.addPlugins(await (0, import_shared2.applyDefaultPlugins)(plugins));
56
- },
57
- async initConfigs() {
58
- const { webpackConfigs } = await (0, import_initConfigs.initConfigs)({
38
+ const webpackProvider = async ({
39
+ plugins,
40
+ pluginStore,
41
+ rsbuildOptions
42
+ }) => {
43
+ const rsbuildConfig = (0, import_shared.pickRsbuildConfig)(rsbuildOptions.rsbuildConfig);
44
+ const context = await (0, import_provider.createContext)(rsbuildOptions, rsbuildConfig, "webpack");
45
+ const pluginAPI = (0, import_provider.getPluginAPI)({ context, pluginStore });
46
+ context.pluginAPI = pluginAPI;
47
+ return {
48
+ bundler: "webpack",
49
+ pluginAPI,
50
+ publicContext: (0, import_provider.createPublicContext)(context),
51
+ async applyDefaultPlugins() {
52
+ pluginStore.addPlugins(await (0, import_shared2.applyDefaultPlugins)(plugins));
53
+ },
54
+ async initConfigs() {
55
+ const { webpackConfigs } = await (0, import_initConfigs.initConfigs)({
56
+ context,
57
+ pluginStore,
58
+ rsbuildOptions
59
+ });
60
+ return webpackConfigs;
61
+ },
62
+ async createCompiler() {
63
+ const { createCompiler } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
64
+ const { webpackConfigs } = await (0, import_initConfigs.initConfigs)({
65
+ context,
66
+ pluginStore,
67
+ rsbuildOptions
68
+ });
69
+ return createCompiler({ context, webpackConfigs });
70
+ },
71
+ async getServerAPIs(options) {
72
+ const { getServerAPIs } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/server")));
73
+ const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
74
+ await (0, import_provider.initRsbuildConfig)({ context, pluginStore });
75
+ return getServerAPIs(
76
+ { context, pluginStore, rsbuildOptions },
77
+ createDevMiddleware,
78
+ options
79
+ );
80
+ },
81
+ async startDevServer(options) {
82
+ const { startDevServer } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/server")));
83
+ const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
84
+ await (0, import_provider.initRsbuildConfig)({
85
+ context,
86
+ pluginStore
87
+ });
88
+ return startDevServer(
89
+ {
59
90
  context,
60
91
  pluginStore,
61
92
  rsbuildOptions
62
- });
63
- return webpackConfigs;
64
- },
65
- async createCompiler() {
66
- const { createCompiler } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
67
- const { webpackConfigs } = await (0, import_initConfigs.initConfigs)({
68
- context,
69
- pluginStore,
70
- rsbuildOptions
71
- });
72
- return createCompiler({ context, webpackConfigs });
73
- },
74
- async getServerAPIs(options) {
75
- const { getServerAPIs } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/server")));
76
- const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
77
- await (0, import_provider.initRsbuildConfig)({ context, pluginStore });
78
- return getServerAPIs(
79
- { context, pluginStore, rsbuildOptions },
80
- // @ts-expect-error compile type mismatch
81
- createDevMiddleware,
82
- options
83
- );
84
- },
85
- async startDevServer(options) {
86
- const { startDevServer } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/server")));
87
- const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
88
- await (0, import_provider.initRsbuildConfig)({
89
- context,
90
- pluginStore
91
- });
92
- return startDevServer(
93
- {
94
- context,
95
- pluginStore,
96
- rsbuildOptions
97
- },
98
- // @ts-expect-error compile type mismatch
99
- createDevMiddleware,
100
- options
101
- );
102
- },
103
- async preview(options) {
104
- const { startProdServer } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/server")));
105
- await (0, import_provider.initRsbuildConfig)({
106
- context,
107
- pluginStore
108
- });
109
- return startProdServer(context, context.config, options);
110
- },
111
- async build(options) {
112
- const { build: buildImpl, webpackBuild } = await Promise.resolve().then(() => __toESM(require("./core/build")));
113
- return buildImpl(
114
- { context, pluginStore, rsbuildOptions },
115
- options,
116
- webpackBuild
117
- );
118
- },
119
- async inspectConfig(inspectOptions) {
120
- const { inspectConfig } = await Promise.resolve().then(() => __toESM(require("./core/inspectConfig")));
121
- return await inspectConfig({
122
- context,
123
- pluginStore,
124
- rsbuildOptions,
125
- inspectOptions
126
- });
127
- }
128
- };
93
+ },
94
+ createDevMiddleware,
95
+ options
96
+ );
97
+ },
98
+ async preview(options) {
99
+ const { startProdServer } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/server")));
100
+ await (0, import_provider.initRsbuildConfig)({
101
+ context,
102
+ pluginStore
103
+ });
104
+ return startProdServer(context, context.config, options);
105
+ },
106
+ async build(options) {
107
+ const { build: buildImpl, webpackBuild } = await Promise.resolve().then(() => __toESM(require("./core/build")));
108
+ return buildImpl(
109
+ { context, pluginStore, rsbuildOptions },
110
+ options,
111
+ webpackBuild
112
+ );
113
+ },
114
+ async inspectConfig(inspectOptions) {
115
+ const { inspectConfig } = await Promise.resolve().then(() => __toESM(require("./core/inspectConfig")));
116
+ return await inspectConfig({
117
+ context,
118
+ pluginStore,
119
+ rsbuildOptions,
120
+ inspectOptions
121
+ });
122
+ }
129
123
  };
130
- }
124
+ };
131
125
  // Annotate the CommonJS export names for ESM import in node:
132
126
  0 && (module.exports = {
133
127
  webpackProvider
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/webpack",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "homepage": "https://rsbuild.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,13 +36,13 @@
36
36
  "terser-webpack-plugin": "5.3.9",
37
37
  "tsconfig-paths-webpack-plugin": "4.1.0",
38
38
  "webpack": "^5.89.0",
39
- "@rsbuild/shared": "0.2.3",
40
- "@rsbuild/core": "0.2.3"
39
+ "@rsbuild/core": "0.2.4",
40
+ "@rsbuild/shared": "0.2.4"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "16.x",
44
44
  "typescript": "^5.3.0",
45
- "@rsbuild/test-helper": "0.2.3"
45
+ "@rsbuild/test-helper": "0.2.4"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public",