@winner-fed/bundler-rsbuild 0.11.12 → 0.11.13

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.
@@ -7,6 +7,7 @@ export interface IOpts {
7
7
  modifyRsbuildConfig?: ModifyRsbuildConfigFn;
8
8
  userConfig?: IConfig;
9
9
  extraBabelPlugins?: IBabelPlugin[];
10
+ extraBabelIncludes?: Array<string | RegExp>;
10
11
  extraBabelPresets?: IBabelPlugin[];
11
12
  }
12
13
  export declare function getRsbuildConfig(opts: IOpts): Promise<RsbuildConfig>;
@@ -8,7 +8,7 @@ interface IOpts {
8
8
  export declare function getOutConfig(opts: IOpts): {
9
9
  assetPrefix: string | undefined;
10
10
  cleanDistPath: any;
11
- copy: import("../types").ICopy[] | string[];
11
+ copy: string[] | import("../types").ICopy[];
12
12
  cssModules: any;
13
13
  dataUriLimit: number;
14
14
  injectStyles: boolean;
@@ -23,6 +23,8 @@ __export(sourceConfig_exports, {
23
23
  resolveDefine: () => resolveDefine
24
24
  });
25
25
  module.exports = __toCommonJS(sourceConfig_exports);
26
+ var import_utils = require("@winner-fed/utils");
27
+ var import_path = require("path");
26
28
  var prefixRE = /^WIN_APP_/;
27
29
  var ENV_SHOULD_PASS = ["HMR", "SOCKET_SERVER", "ERROR_OVERLAY"];
28
30
  var SOCKET_IGNORE_HOSTS = ["0.0.0.0", "127.0.0.1", "localhost"];
@@ -68,16 +70,48 @@ function resolveDefine(opts) {
68
70
  };
69
71
  }
70
72
  function getSourceConfig(opts) {
71
- const { userConfig, entry } = opts;
73
+ const { userConfig, entry, cwd } = opts;
72
74
  let tsconfigPath = "tsconfig.json";
73
75
  if ((userConfig == null ? void 0 : userConfig.alias) && (userConfig == null ? void 0 : userConfig.alias["@@"])) {
74
76
  tsconfigPath = `${userConfig == null ? void 0 : userConfig.alias["@@"]}/tsconfig.json`;
75
77
  }
78
+ let extraInclude = [];
79
+ if (Array.isArray(userConfig == null ? void 0 : userConfig.extraBabelIncludes) && (userConfig == null ? void 0 : userConfig.extraBabelIncludes.length)) {
80
+ extraInclude = userConfig.extraBabelIncludes.map((p) => {
81
+ if (import_utils.lodash.isRegExp(p)) {
82
+ return p;
83
+ }
84
+ if ((0, import_path.isAbsolute)(p)) {
85
+ return p;
86
+ }
87
+ try {
88
+ if (p.startsWith("./")) {
89
+ return require.resolve(p, { paths: [cwd] });
90
+ }
91
+ return (0, import_path.dirname)(
92
+ import_utils.resolve.sync(`${p}/package.json`, {
93
+ basedir: cwd,
94
+ // same behavior as webpack, to ensure `include` paths matched
95
+ // ref: https://webpack.js.org/configuration/resolve/#resolvesymlinks
96
+ preserveSymlinks: false
97
+ })
98
+ );
99
+ } catch (e) {
100
+ if (e.code === "MODULE_NOT_FOUND") {
101
+ throw new Error("Cannot resolve extraBabelIncludes: " + p, {
102
+ cause: e
103
+ });
104
+ }
105
+ throw e;
106
+ }
107
+ });
108
+ }
76
109
  return {
77
110
  alias: userConfig.alias || {},
78
111
  define: resolveDefine(opts),
79
112
  entry,
80
- tsconfigPath
113
+ tsconfigPath,
114
+ include: [...extraInclude]
81
115
  };
82
116
  }
83
117
  // Annotate the CommonJS export names for ESM import in node:
package/dist/schema.js CHANGED
@@ -75,6 +75,7 @@ function getSchemas() {
75
75
  zod.string(),
76
76
  zod.function()
77
77
  ]),
78
+ extraBabelIncludes: ({ zod }) => zod.array(zod.union([zod.string(), zod.instanceof(RegExp)])),
78
79
  extraBabelPlugins: ({ zod }) => zod.array(zod.union([zod.string(), zod.array(zod.any())])),
79
80
  extraBabelPresets: ({ zod }) => zod.array(zod.union([zod.string(), zod.array(zod.any())])),
80
81
  extraPostCSSPlugins: ({ zod }) => zod.array(zod.any()),
package/dist/types.d.ts CHANGED
@@ -38,6 +38,7 @@ export interface IConfig {
38
38
  externals?: Record<string, string>;
39
39
  extraBabelPlugins?: IBabelPlugin[];
40
40
  extraBabelPresets?: IBabelPlugin[];
41
+ extraBabelIncludes?: Array<string | RegExp>;
41
42
  extraPostCSSPlugins?: any[];
42
43
  hash?: boolean;
43
44
  manifest?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@winner-fed/bundler-rsbuild",
3
- "version": "0.11.12",
3
+ "version": "0.11.13",
4
4
  "description": "@winner-fed/bundler-rsbuild",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -9,15 +9,15 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@rsbuild/core": "1.0.18",
13
- "@rsbuild/plugin-babel": "1.0.2",
14
- "@rsbuild/plugin-less": "1.0.3",
12
+ "@rsbuild/core": "1.1.0",
13
+ "@rsbuild/plugin-babel": "1.0.3",
14
+ "@rsbuild/plugin-less": "1.1.0",
15
15
  "@rsbuild/plugin-node-polyfill": "1.2.0",
16
- "@rsbuild/plugin-sass": "1.0.4",
17
- "@rsbuild/plugin-stylus": "1.0.4",
16
+ "@rsbuild/plugin-sass": "1.1.0",
17
+ "@rsbuild/plugin-stylus": "1.0.5",
18
18
  "@rsbuild/plugin-type-check": "1.0.1",
19
- "@winner-fed/bundler-utils": "0.11.12",
20
- "@winner-fed/utils": "0.11.12"
19
+ "@winner-fed/bundler-utils": "0.11.13",
20
+ "@winner-fed/utils": "0.11.13"
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "public"