@workleap/rslib-configs 0.0.1 → 1.0.2
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/CHANGELOG.md +19 -0
- package/dist/applyTransformers.js +2 -0
- package/dist/applyTransformers.js.map +1 -0
- package/dist/assertions.d.ts +1 -0
- package/dist/assertions.js +11 -0
- package/dist/assertions.js.map +1 -0
- package/dist/build.d.ts +2 -3
- package/dist/build.js +16 -15
- package/dist/build.js.map +1 -0
- package/dist/dev.d.ts +2 -3
- package/dist/dev.js +17 -16
- package/dist/dev.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/storybook.js +2 -0
- package/dist/storybook.js.map +1 -0
- package/package.json +3 -4
- package/src/assertions.ts +6 -0
- package/src/build.ts +16 -23
- package/src/dev.ts +16 -23
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @workleap/rslib-configs
|
|
2
|
+
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#232](https://github.com/gsoft-inc/wl-web-configs/pull/232) [`803f0ed`](https://github.com/gsoft-inc/wl-web-configs/commit/803f0edef6dc2c0525e1522d209c517e0e119da6) Thanks [@patricklafrance](https://github.com/patricklafrance)! - React and SVGR code transformation are not activated by default anymore for the dev and build configs.
|
|
8
|
+
|
|
9
|
+
## 1.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#230](https://github.com/gsoft-inc/wl-web-configs/pull/230) [`0a4279c`](https://github.com/gsoft-inc/wl-web-configs/commit/0a4279c40b7c2ea76c7e1884a8e2fd744ca9b7c1) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Packages now includes the source codes and sourcemap.
|
|
14
|
+
|
|
15
|
+
## 1.0.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- [#228](https://github.com/gsoft-inc/wl-web-configs/pull/228) [`c7837d4`](https://github.com/gsoft-inc/wl-web-configs/commit/c7837d4406c42412a02270e4ff3e0e51157a1ed1) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Initial major release of the Rslib shared configs.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyTransformers.js","sources":["webpack://@workleap/rslib-configs/./src/applyTransformers.ts"],"sourcesContent":["import type { RslibConfig } from \"@rslib/core\";\n\nexport interface RslibConfigTransformerContext {\n environment: \"dev\" | \"build\" | \"storybook\";\n}\n\nexport type RslibConfigTransformer = (config: RslibConfig, context: RslibConfigTransformerContext) => RslibConfig;\n\nexport function applyTransformers(config: RslibConfig, transformers: RslibConfigTransformer[], context: RslibConfigTransformerContext) {\n return transformers.reduce((acc, transformer) => transformer(acc, context), config);\n}\n"],"names":["applyTransformers","config","transformers","context","acc","transformer"],"mappings":";;AAQO,SAASA,kBAAkBC,MAAmB,EAAEC,YAAsC,EAAEC,OAAsC;IACjI,OAAOD,aAAa,MAAM,CAAC,CAACE,KAAKC,cAAgBA,YAAYD,KAAKD,UAAUF;AAChF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isFunction(value: unknown): value is (...args: any[]) => any;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
;// CONCATENATED MODULE: ./src/assertions.ts?__rslib_entry__
|
|
3
|
+
// Using "unknown" loses the typings.
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
function isFunction(value) {
|
|
6
|
+
return typeof value === "function";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { isFunction };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=assertions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions.js","sources":["webpack://@workleap/rslib-configs/./src/assertions.ts"],"sourcesContent":["// Using \"unknown\" loses the typings.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isFunction(value: unknown): value is (...args: any[]) => any {\n return typeof value === \"function\";\n}\n\n"],"names":["isFunction","value"],"mappings":";;AAAA,qCAAqC;AACrC,8DAA8D;AACvD,SAASA,WAAWC,KAAc;IACrC,OAAO,OAAOA,UAAU;AAC5B"}
|
package/dist/build.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export type DefineBuildDefineReactPluginConfigFunction = (defaultOptions: Plugin
|
|
|
7
7
|
export type DefineBuildSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;
|
|
8
8
|
export interface DefineBuildConfigOptions {
|
|
9
9
|
entry?: RsbuildConfigEntry;
|
|
10
|
-
format?: "esm" | "cjs";
|
|
11
10
|
syntax?: Syntax;
|
|
12
11
|
bundle?: boolean;
|
|
13
12
|
tsconfigPath?: string;
|
|
@@ -16,8 +15,8 @@ export interface DefineBuildConfigOptions {
|
|
|
16
15
|
distPath?: DistPathConfig;
|
|
17
16
|
plugins?: RsbuildPlugins;
|
|
18
17
|
sourceMap?: boolean | SourceMap;
|
|
19
|
-
react?:
|
|
20
|
-
svgr?:
|
|
18
|
+
react?: true | DefineBuildDefineReactPluginConfigFunction;
|
|
19
|
+
svgr?: true | DefineBuildSvgrPluginConfigFunction;
|
|
21
20
|
transformers?: RslibConfigTransformer[];
|
|
22
21
|
}
|
|
23
22
|
export declare function defineBuildConfig(options?: DefineBuildConfigOptions): import("@rslib/core").RslibConfig;
|
package/dist/build.js
CHANGED
|
@@ -2,6 +2,7 @@ import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__ from "@rs
|
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_svgr_14547cd0__ from "@rsbuild/plugin-svgr";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__rslib_core_68de5877__ from "@rslib/core";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE__applyTransformers_js_2d4fcf6d__ from "./applyTransformers.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__assertions_js_8ee55c0f__ from "./assertions.js";
|
|
5
6
|
|
|
6
7
|
;// CONCATENATED MODULE: external "@rsbuild/plugin-react"
|
|
7
8
|
|
|
@@ -11,24 +12,21 @@ import * as __WEBPACK_EXTERNAL_MODULE__applyTransformers_js_2d4fcf6d__ from "./a
|
|
|
11
12
|
|
|
12
13
|
;// CONCATENATED MODULE: external "./applyTransformers.js"
|
|
13
14
|
|
|
15
|
+
;// CONCATENATED MODULE: external "./assertions.js"
|
|
16
|
+
|
|
14
17
|
;// CONCATENATED MODULE: ./src/build.ts?__rslib_entry__
|
|
15
18
|
|
|
16
19
|
|
|
17
20
|
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
return options;
|
|
21
|
-
}
|
|
22
|
-
function defineSvgrPluginConfig(options) {
|
|
23
|
-
return options;
|
|
24
|
-
}
|
|
22
|
+
|
|
25
23
|
function defineBuildConfig(options = {}) {
|
|
26
|
-
const { entry: entryValue,
|
|
24
|
+
const { entry: entryValue, syntax = "esnext", bundle = false, tsconfigPath, dts = true, target = "web", distPath = {
|
|
27
25
|
root: "./dist"
|
|
28
26
|
}, plugins = [], sourceMap = {
|
|
29
27
|
js: "source-map",
|
|
30
28
|
css: true
|
|
31
|
-
}, react =
|
|
29
|
+
}, react = false, svgr = false, transformers = [] } = options;
|
|
32
30
|
if (!bundle && !tsconfigPath) {
|
|
33
31
|
throw new Error("[rslib-configs] When the \"bundle\" option is \"false\", a \"tsconfigPath\" option must be provided. We recommend including a tsconfig.build.json file specifically for compiling the library project.");
|
|
34
32
|
}
|
|
@@ -41,11 +39,16 @@ function defineBuildConfig(options = {}) {
|
|
|
41
39
|
] : "./src/**"
|
|
42
40
|
};
|
|
43
41
|
}
|
|
42
|
+
const svgrDefaultOptions = {
|
|
43
|
+
svgrOptions: {
|
|
44
|
+
exportType: "named"
|
|
45
|
+
}
|
|
46
|
+
};
|
|
44
47
|
const config = (0,__WEBPACK_EXTERNAL_MODULE__rslib_core_68de5877__.defineConfig)({
|
|
45
48
|
mode: "production",
|
|
46
49
|
lib: [
|
|
47
50
|
{
|
|
48
|
-
format,
|
|
51
|
+
format: "esm",
|
|
49
52
|
syntax,
|
|
50
53
|
bundle,
|
|
51
54
|
dts
|
|
@@ -63,12 +66,8 @@ function defineBuildConfig(options = {}) {
|
|
|
63
66
|
sourceMap
|
|
64
67
|
},
|
|
65
68
|
plugins: [
|
|
66
|
-
react && (0,__WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__.pluginReact)(react({})),
|
|
67
|
-
svgr && (0,__WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_svgr_14547cd0__.pluginSvgr)(svgr(
|
|
68
|
-
svgrOptions: {
|
|
69
|
-
exportType: "named"
|
|
70
|
-
}
|
|
71
|
-
})),
|
|
69
|
+
react && (0,__WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__.pluginReact)((0,__WEBPACK_EXTERNAL_MODULE__assertions_js_8ee55c0f__.isFunction)(react) ? react({}) : {}),
|
|
70
|
+
svgr && (0,__WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_svgr_14547cd0__.pluginSvgr)((0,__WEBPACK_EXTERNAL_MODULE__assertions_js_8ee55c0f__.isFunction)(svgr) ? svgr(svgrDefaultOptions) : svgrDefaultOptions),
|
|
72
71
|
...plugins
|
|
73
72
|
].filter(Boolean)
|
|
74
73
|
});
|
|
@@ -79,3 +78,5 @@ function defineBuildConfig(options = {}) {
|
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
export { defineBuildConfig };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sources":["webpack://@workleap/rslib-configs/./src/build.ts"],"sourcesContent":["import type { DistPathConfig, RsbuildPlugins, SourceMap } from \"@rsbuild/core\";\nimport { pluginReact, type PluginReactOptions } from \"@rsbuild/plugin-react\";\nimport { pluginSvgr, type PluginSvgrOptions } from \"@rsbuild/plugin-svgr\";\nimport { defineConfig, type Dts, type RsbuildConfigEntry, type RsbuildConfigOutputTarget, type Syntax } from \"@rslib/core\";\nimport { applyTransformers, type RslibConfigTransformer } from \"./applyTransformers.ts\";\nimport { isFunction } from \"./assertions.ts\";\n\nexport type DefineBuildDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;\nexport type DefineBuildSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;\n\nexport interface DefineBuildConfigOptions {\n entry?: RsbuildConfigEntry;\n syntax?: Syntax;\n bundle?: boolean;\n tsconfigPath?: string;\n dts?: Dts;\n target?: RsbuildConfigOutputTarget;\n distPath?: DistPathConfig;\n plugins?: RsbuildPlugins;\n sourceMap?: boolean | SourceMap;\n react?: true | DefineBuildDefineReactPluginConfigFunction;\n svgr? : true | DefineBuildSvgrPluginConfigFunction;\n transformers?: RslibConfigTransformer[];\n}\n\nexport function defineBuildConfig(options: DefineBuildConfigOptions = {}) {\n const {\n entry: entryValue,\n syntax = \"esnext\",\n bundle = false,\n tsconfigPath,\n dts = true,\n target = \"web\",\n distPath = {\n root: \"./dist\"\n },\n plugins = [],\n sourceMap = {\n js: \"source-map\",\n css: true\n },\n react = false,\n svgr = false,\n transformers = []\n } = options;\n\n if (!bundle && !tsconfigPath) {\n throw new Error(\"[rslib-configs] When the \\\"bundle\\\" option is \\\"false\\\", a \\\"tsconfigPath\\\" option must be provided. We recommend including a tsconfig.build.json file specifically for compiling the library project.\");\n }\n\n let entry = entryValue;\n\n if (!entry) {\n entry = {\n index: bundle ? [\"./src/index.ts\", \"./src/index.js\"] : \"./src/**\"\n };\n }\n\n const svgrDefaultOptions: PluginSvgrOptions = {\n svgrOptions: {\n exportType: \"named\"\n }\n };\n\n const config = defineConfig({\n mode: \"production\",\n lib: [{\n format: \"esm\",\n syntax,\n bundle,\n dts\n }],\n source: {\n entry,\n tsconfigPath\n },\n output: {\n target,\n distPath,\n cleanDistPath: true,\n minify: false,\n sourceMap\n },\n plugins: ([\n react && pluginReact(isFunction(react) ? react({}) : {}),\n svgr && pluginSvgr(isFunction(svgr) ? svgr(svgrDefaultOptions) : svgrDefaultOptions),\n ...plugins\n ] as RsbuildPlugins).filter(Boolean)\n });\n\n const transformedConfig = applyTransformers(config, transformers, {\n environment: \"build\"\n });\n\n return defineConfig(transformedConfig);\n}\n"],"names":["pluginReact","pluginSvgr","defineConfig","applyTransformers","isFunction","defineBuildConfig","options","entryValue","syntax","bundle","tsconfigPath","dts","target","distPath","plugins","sourceMap","react","svgr","transformers","Error","entry","svgrDefaultOptions","config","Boolean","transformedConfig"],"mappings":";;;;;;;;;;;;;;;;;AAC6E;AACH;AACiD;AACnC;AAC3C;AAoBtC,SAASK,kBAAkBC,UAAoC,CAAC,CAAC;IACpE,MAAM,EACF,OAAOC,UAAU,EACjBC,SAAS,QAAQ,EACjBC,SAAS,KAAK,EACdC,YAAY,EACZC,MAAM,IAAI,EACVC,SAAS,KAAK,EACdC,WAAW;QACP,MAAM;IACV,CAAC,EACDC,UAAU,EAAE,EACZC,YAAY;QACR,IAAI;QACJ,KAAK;IACT,CAAC,EACDC,QAAQ,KAAK,EACbC,OAAO,KAAK,EACZC,eAAe,EAAE,EACpB,GAAGZ;IAEJ,IAAI,CAACG,UAAU,CAACC,cAAc;QAC1B,MAAM,IAAIS,MAAM;IACpB;IAEA,IAAIC,QAAQb;IAEZ,IAAI,CAACa,OAAO;QACRA,QAAQ;YACJ,OAAOX,SAAS;gBAAC;gBAAkB;aAAiB,GAAG;QAC3D;IACJ;IAEA,MAAMY,qBAAwC;QAC1C,aAAa;YACT,YAAY;QAChB;IACJ;IAEA,MAAMC,SAASpB,iEAAYA,CAAC;QACxB,MAAM;QACN,KAAK;YAAC;gBACF,QAAQ;gBACRM;gBACAC;gBACAE;YACJ;SAAE;QACF,QAAQ;YACJS;YACAV;QACJ;QACA,QAAQ;YACJE;YACAC;YACA,eAAe;YACf,QAAQ;YACRE;QACJ;QACA,SAAU;YACNC,SAAShB,0EAAWA,CAACI,kEAAUA,CAACY,SAASA,MAAM,CAAC,KAAK,CAAC;YACtDC,QAAQhB,wEAAUA,CAACG,kEAAUA,CAACa,QAAQA,KAAKI,sBAAsBA;eAC9DP;SACN,CAAoB,MAAM,CAACS;IAChC;IAEA,MAAMC,oBAAoBrB,gFAAiBA,CAACmB,QAAQJ,cAAc;QAC9D,aAAa;IACjB;IAEA,OAAOhB,iEAAYA,CAACsB;AACxB"}
|
package/dist/dev.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export type DefineDevDefineReactPluginConfigFunction = (defaultOptions: PluginRe
|
|
|
7
7
|
export type DefineDevSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;
|
|
8
8
|
export interface DefineDevConfigOptions {
|
|
9
9
|
entry?: RsbuildConfigEntry;
|
|
10
|
-
format?: "esm" | "cjs";
|
|
11
10
|
syntax?: Syntax;
|
|
12
11
|
bundle?: boolean;
|
|
13
12
|
tsconfigPath?: string;
|
|
@@ -16,8 +15,8 @@ export interface DefineDevConfigOptions {
|
|
|
16
15
|
distPath?: DistPathConfig;
|
|
17
16
|
plugins?: RsbuildPlugins;
|
|
18
17
|
sourceMap?: boolean | SourceMap;
|
|
19
|
-
react?:
|
|
20
|
-
svgr?:
|
|
18
|
+
react?: true | DefineDevDefineReactPluginConfigFunction;
|
|
19
|
+
svgr?: true | DefineDevSvgrPluginConfigFunction;
|
|
21
20
|
transformers?: RslibConfigTransformer[];
|
|
22
21
|
}
|
|
23
22
|
export declare function defineDevConfig(options?: DefineDevConfigOptions): import("@rslib/core").RslibConfig;
|
package/dist/dev.js
CHANGED
|
@@ -2,6 +2,7 @@ import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__ from "@rs
|
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_svgr_14547cd0__ from "@rsbuild/plugin-svgr";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__rslib_core_68de5877__ from "@rslib/core";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE__applyTransformers_js_2d4fcf6d__ from "./applyTransformers.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__assertions_js_8ee55c0f__ from "./assertions.js";
|
|
5
6
|
|
|
6
7
|
;// CONCATENATED MODULE: external "@rsbuild/plugin-react"
|
|
7
8
|
|
|
@@ -11,24 +12,21 @@ import * as __WEBPACK_EXTERNAL_MODULE__applyTransformers_js_2d4fcf6d__ from "./a
|
|
|
11
12
|
|
|
12
13
|
;// CONCATENATED MODULE: external "./applyTransformers.js"
|
|
13
14
|
|
|
15
|
+
;// CONCATENATED MODULE: external "./assertions.js"
|
|
16
|
+
|
|
14
17
|
;// CONCATENATED MODULE: ./src/dev.ts?__rslib_entry__
|
|
15
18
|
|
|
16
19
|
|
|
17
20
|
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
return options;
|
|
21
|
-
}
|
|
22
|
-
function defineSvgrPluginConfig(options) {
|
|
23
|
-
return options;
|
|
24
|
-
}
|
|
22
|
+
|
|
25
23
|
function defineDevConfig(options = {}) {
|
|
26
|
-
const { entry: entryValue,
|
|
24
|
+
const { entry: entryValue, syntax = "esnext", bundle = false, tsconfigPath, dts = false, target = "web", distPath = {
|
|
27
25
|
root: "./dist"
|
|
28
26
|
}, plugins = [], sourceMap = {
|
|
29
27
|
js: "cheap-module-source-map",
|
|
30
28
|
css: true
|
|
31
|
-
}, react =
|
|
29
|
+
}, react = false, svgr = false, transformers = [] } = options;
|
|
32
30
|
if (!bundle && !tsconfigPath) {
|
|
33
31
|
throw new Error("[rslib-configs] When the \"bundle\" option is \"false\", a \"tsconfigPath\" option must be provided. We recommend including a tsconfig.build.json file specifically for compiling the library project.");
|
|
34
32
|
}
|
|
@@ -41,11 +39,16 @@ function defineDevConfig(options = {}) {
|
|
|
41
39
|
] : "./src/**"
|
|
42
40
|
};
|
|
43
41
|
}
|
|
42
|
+
const svgrDefaultOptions = {
|
|
43
|
+
svgrOptions: {
|
|
44
|
+
exportType: "named"
|
|
45
|
+
}
|
|
46
|
+
};
|
|
44
47
|
const config = (0,__WEBPACK_EXTERNAL_MODULE__rslib_core_68de5877__.defineConfig)({
|
|
45
48
|
mode: "development",
|
|
46
49
|
lib: [
|
|
47
50
|
{
|
|
48
|
-
format,
|
|
51
|
+
format: "esm",
|
|
49
52
|
syntax,
|
|
50
53
|
bundle,
|
|
51
54
|
dts
|
|
@@ -63,14 +66,10 @@ function defineDevConfig(options = {}) {
|
|
|
63
66
|
sourceMap
|
|
64
67
|
},
|
|
65
68
|
plugins: [
|
|
66
|
-
react && (0,__WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__.pluginReact)(react({})),
|
|
67
|
-
svgr && (0,__WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_svgr_14547cd0__.pluginSvgr)(svgr(
|
|
68
|
-
svgrOptions: {
|
|
69
|
-
exportType: "named"
|
|
70
|
-
}
|
|
71
|
-
})),
|
|
69
|
+
react && (0,__WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_react_7b149ee4__.pluginReact)((0,__WEBPACK_EXTERNAL_MODULE__assertions_js_8ee55c0f__.isFunction)(react) ? react({}) : {}),
|
|
70
|
+
svgr && (0,__WEBPACK_EXTERNAL_MODULE__rsbuild_plugin_svgr_14547cd0__.pluginSvgr)((0,__WEBPACK_EXTERNAL_MODULE__assertions_js_8ee55c0f__.isFunction)(svgr) ? svgr(svgrDefaultOptions) : svgrDefaultOptions),
|
|
72
71
|
...plugins
|
|
73
|
-
]
|
|
72
|
+
].filter(Boolean)
|
|
74
73
|
});
|
|
75
74
|
const transformedConfig = (0,__WEBPACK_EXTERNAL_MODULE__applyTransformers_js_2d4fcf6d__.applyTransformers)(config, transformers, {
|
|
76
75
|
environment: "dev"
|
|
@@ -79,3 +78,5 @@ function defineDevConfig(options = {}) {
|
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
export { defineDevConfig };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sources":["webpack://@workleap/rslib-configs/./src/dev.ts"],"sourcesContent":["import type { DistPathConfig, RsbuildPlugins, SourceMap } from \"@rsbuild/core\";\nimport { pluginReact, type PluginReactOptions } from \"@rsbuild/plugin-react\";\nimport { pluginSvgr, type PluginSvgrOptions } from \"@rsbuild/plugin-svgr\";\nimport { defineConfig, type Dts, type RsbuildConfigEntry, type RsbuildConfigOutputTarget, type Syntax } from \"@rslib/core\";\nimport { applyTransformers, type RslibConfigTransformer } from \"./applyTransformers.ts\";\nimport { isFunction } from \"./assertions.ts\";\n\nexport type DefineDevDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;\nexport type DefineDevSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;\n\nexport interface DefineDevConfigOptions {\n entry?: RsbuildConfigEntry;\n syntax?: Syntax;\n bundle?: boolean;\n tsconfigPath?: string;\n dts?: Dts;\n target?: RsbuildConfigOutputTarget;\n distPath?: DistPathConfig;\n plugins?: RsbuildPlugins;\n sourceMap?: boolean | SourceMap;\n react?: true | DefineDevDefineReactPluginConfigFunction;\n svgr? : true | DefineDevSvgrPluginConfigFunction;\n transformers?: RslibConfigTransformer[];\n}\n\nexport function defineDevConfig(options: DefineDevConfigOptions = {}) {\n const {\n entry: entryValue,\n syntax = \"esnext\",\n bundle = false,\n tsconfigPath,\n dts = false,\n target = \"web\",\n distPath = {\n root: \"./dist\"\n },\n plugins = [],\n sourceMap = {\n js: \"cheap-module-source-map\",\n css: true\n },\n react = false,\n svgr = false,\n transformers = []\n } = options;\n\n if (!bundle && !tsconfigPath) {\n throw new Error(\"[rslib-configs] When the \\\"bundle\\\" option is \\\"false\\\", a \\\"tsconfigPath\\\" option must be provided. We recommend including a tsconfig.build.json file specifically for compiling the library project.\");\n }\n\n let entry = entryValue;\n\n if (!entry) {\n entry = {\n index: bundle ? [\"./src/index.ts\", \"./src/index.js\"] : \"./src/**\"\n };\n }\n\n const svgrDefaultOptions: PluginSvgrOptions = {\n svgrOptions: {\n exportType: \"named\"\n }\n };\n\n const config = defineConfig({\n mode: \"development\",\n lib: [{\n format: \"esm\",\n syntax,\n bundle,\n dts\n }],\n source: {\n entry,\n tsconfigPath\n },\n output: {\n target,\n distPath,\n cleanDistPath: true,\n minify: false,\n sourceMap\n },\n plugins: ([\n react && pluginReact(isFunction(react) ? react({}) : {}),\n svgr && pluginSvgr(isFunction(svgr) ? svgr(svgrDefaultOptions) : svgrDefaultOptions),\n ...plugins\n ] as RsbuildPlugins).filter(Boolean)\n });\n\n const transformedConfig = applyTransformers(config, transformers, {\n environment: \"dev\"\n });\n\n return defineConfig(transformedConfig);\n}\n"],"names":["pluginReact","pluginSvgr","defineConfig","applyTransformers","isFunction","defineDevConfig","options","entryValue","syntax","bundle","tsconfigPath","dts","target","distPath","plugins","sourceMap","react","svgr","transformers","Error","entry","svgrDefaultOptions","config","Boolean","transformedConfig"],"mappings":";;;;;;;;;;;;;;;;;AAC6E;AACH;AACiD;AACnC;AAC3C;AAoBtC,SAASK,gBAAgBC,UAAkC,CAAC,CAAC;IAChE,MAAM,EACF,OAAOC,UAAU,EACjBC,SAAS,QAAQ,EACjBC,SAAS,KAAK,EACdC,YAAY,EACZC,MAAM,KAAK,EACXC,SAAS,KAAK,EACdC,WAAW;QACP,MAAM;IACV,CAAC,EACDC,UAAU,EAAE,EACZC,YAAY;QACR,IAAI;QACJ,KAAK;IACT,CAAC,EACDC,QAAQ,KAAK,EACbC,OAAO,KAAK,EACZC,eAAe,EAAE,EACpB,GAAGZ;IAEJ,IAAI,CAACG,UAAU,CAACC,cAAc;QAC1B,MAAM,IAAIS,MAAM;IACpB;IAEA,IAAIC,QAAQb;IAEZ,IAAI,CAACa,OAAO;QACRA,QAAQ;YACJ,OAAOX,SAAS;gBAAC;gBAAkB;aAAiB,GAAG;QAC3D;IACJ;IAEA,MAAMY,qBAAwC;QAC1C,aAAa;YACT,YAAY;QAChB;IACJ;IAEA,MAAMC,SAASpB,iEAAYA,CAAC;QACxB,MAAM;QACN,KAAK;YAAC;gBACF,QAAQ;gBACRM;gBACAC;gBACAE;YACJ;SAAE;QACF,QAAQ;YACJS;YACAV;QACJ;QACA,QAAQ;YACJE;YACAC;YACA,eAAe;YACf,QAAQ;YACRE;QACJ;QACA,SAAU;YACNC,SAAShB,0EAAWA,CAACI,kEAAUA,CAACY,SAASA,MAAM,CAAC,KAAK,CAAC;YACtDC,QAAQhB,wEAAUA,CAACG,kEAAUA,CAACa,QAAQA,KAAKI,sBAAsBA;eAC9DP;SACN,CAAoB,MAAM,CAACS;IAChC;IAEA,MAAMC,oBAAoBrB,gFAAiBA,CAACmB,QAAQJ,cAAc;QAC9D,aAAa;IACjB;IAEA,OAAOhB,iEAAYA,CAACsB;AACxB"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["webpack://@workleap/rslib-configs/./src/index.ts"],"sourcesContent":["export type { RslibConfigTransformer, RslibConfigTransformerContext } from \"./applyTransformers.ts\";\nexport * from \"./build.ts\";\nexport * from \"./dev.ts\";\nexport * from \"./storybook.ts\";\n\n"],"names":[],"mappings":";;;;;AAC2B;AACF;AACM"}
|
package/dist/storybook.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storybook.js","sources":["webpack://@workleap/rslib-configs/./src/storybook.ts"],"sourcesContent":["import type { RsbuildPlugins, SourceMap } from \"@rsbuild/core\";\nimport { pluginReact, type PluginReactOptions } from \"@rsbuild/plugin-react\";\nimport { pluginSvgr, type PluginSvgrOptions } from \"@rsbuild/plugin-svgr\";\nimport { defineConfig } from \"@rslib/core\";\nimport { applyTransformers, type RslibConfigTransformer } from \"./applyTransformers.ts\";\n\nexport type DefineStorybookDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;\nexport type DefineStorybookSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;\n\nexport interface DefineStorybookConfigOptions {\n plugins?: RsbuildPlugins;\n sourceMap?: boolean | SourceMap;\n react?: false | DefineStorybookDefineReactPluginConfigFunction;\n svgr? : false | DefineStorybookSvgrPluginConfigFunction;\n transformers?: RslibConfigTransformer[];\n}\n\nfunction defaultDefineReactPluginConfig(options: PluginReactOptions) {\n return options;\n}\n\nfunction defineSvgrPluginConfig(options: PluginSvgrOptions) {\n return options;\n}\n\nexport function defineStorybookConfig(options: DefineStorybookConfigOptions = {}) {\n const {\n plugins = [],\n sourceMap = {\n js: \"cheap-module-source-map\",\n css: true\n },\n react = defaultDefineReactPluginConfig,\n svgr = defineSvgrPluginConfig,\n transformers = []\n } = options;\n\n const config = defineConfig({\n lib: [{\n dts: false\n }],\n output: {\n target: \"web\",\n // Setting the clean option to true breaks the Storybook integration.\n cleanDistPath: false,\n minify: false,\n sourceMap\n },\n plugins: [\n react && pluginReact(react({})),\n svgr && pluginSvgr(svgr({\n svgrOptions: {\n exportType: \"named\"\n }\n })),\n ...plugins\n ]\n });\n\n const transformedConfig = applyTransformers(config, transformers, {\n environment: \"storybook\"\n });\n\n return defineConfig(transformedConfig);\n}\n"],"names":["pluginReact","pluginSvgr","defineConfig","applyTransformers","defaultDefineReactPluginConfig","options","defineSvgrPluginConfig","defineStorybookConfig","plugins","sourceMap","react","svgr","transformers","config","transformedConfig"],"mappings":";;;;;;;;;;;;;;AAC6E;AACH;AAC/B;AAC6C;AAaxF,SAASI,+BAA+BC,OAA2B;IAC/D,OAAOA;AACX;AAEA,SAASC,uBAAuBD,OAA0B;IACtD,OAAOA;AACX;AAEO,SAASE,sBAAsBF,UAAwC,CAAC,CAAC;IAC5E,MAAM,EACFG,UAAU,EAAE,EACZC,YAAY;QACR,IAAI;QACJ,KAAK;IACT,CAAC,EACDC,QAAQN,8BAA8B,EACtCO,OAAOL,sBAAsB,EAC7BM,eAAe,EAAE,EACpB,GAAGP;IAEJ,MAAMQ,SAASX,iEAAYA,CAAC;QACxB,KAAK;YAAC;gBACF,KAAK;YACT;SAAE;QACF,QAAQ;YACJ,QAAQ;YACR,qEAAqE;YACrE,eAAe;YACf,QAAQ;YACRO;QACJ;QACA,SAAS;YACLC,SAASV,0EAAWA,CAACU,MAAM,CAAC;YAC5BC,QAAQV,wEAAUA,CAACU,KAAK;gBACpB,aAAa;oBACT,YAAY;gBAChB;YACJ;eACGH;SACN;IACL;IAEA,MAAMM,oBAAoBX,gFAAiBA,CAACU,QAAQD,cAAc;QAC9D,aAAa;IACjB;IAEA,OAAOV,iEAAYA,CAACY;AACxB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@workleap/rslib-configs",
|
|
3
3
|
"author": "Workleap",
|
|
4
4
|
"description": "Workleap recommended Rslib configurations.",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "1.0.2",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -41,14 +41,13 @@
|
|
|
41
41
|
"@swc/core": "1.10.7",
|
|
42
42
|
"@swc/jest": "0.2.37",
|
|
43
43
|
"@types/jest": "29.5.14",
|
|
44
|
-
"@types/node": "22.10.
|
|
44
|
+
"@types/node": "22.10.7",
|
|
45
45
|
"@typescript-eslint/parser": "8.20.0",
|
|
46
46
|
"eslint": "8.57.0",
|
|
47
47
|
"jest": "29.7.0",
|
|
48
48
|
"ts-node": "10.9.2",
|
|
49
49
|
"typescript": "5.5.4",
|
|
50
|
-
"@workleap/eslint-plugin": "3.2.
|
|
51
|
-
"@workleap/swc-configs": "2.2.3",
|
|
50
|
+
"@workleap/eslint-plugin": "3.2.6",
|
|
52
51
|
"@workleap/typescript-configs": "3.0.2"
|
|
53
52
|
},
|
|
54
53
|
"scripts": {
|
package/src/build.ts
CHANGED
|
@@ -3,13 +3,13 @@ import { pluginReact, type PluginReactOptions } from "@rsbuild/plugin-react";
|
|
|
3
3
|
import { pluginSvgr, type PluginSvgrOptions } from "@rsbuild/plugin-svgr";
|
|
4
4
|
import { defineConfig, type Dts, type RsbuildConfigEntry, type RsbuildConfigOutputTarget, type Syntax } from "@rslib/core";
|
|
5
5
|
import { applyTransformers, type RslibConfigTransformer } from "./applyTransformers.ts";
|
|
6
|
+
import { isFunction } from "./assertions.ts";
|
|
6
7
|
|
|
7
8
|
export type DefineBuildDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;
|
|
8
9
|
export type DefineBuildSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;
|
|
9
10
|
|
|
10
11
|
export interface DefineBuildConfigOptions {
|
|
11
12
|
entry?: RsbuildConfigEntry;
|
|
12
|
-
format?: "esm" | "cjs";
|
|
13
13
|
syntax?: Syntax;
|
|
14
14
|
bundle?: boolean;
|
|
15
15
|
tsconfigPath?: string;
|
|
@@ -18,23 +18,14 @@ export interface DefineBuildConfigOptions {
|
|
|
18
18
|
distPath?: DistPathConfig;
|
|
19
19
|
plugins?: RsbuildPlugins;
|
|
20
20
|
sourceMap?: boolean | SourceMap;
|
|
21
|
-
react?:
|
|
22
|
-
svgr? :
|
|
21
|
+
react?: true | DefineBuildDefineReactPluginConfigFunction;
|
|
22
|
+
svgr? : true | DefineBuildSvgrPluginConfigFunction;
|
|
23
23
|
transformers?: RslibConfigTransformer[];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function defaultDefineReactPluginConfig(options: PluginReactOptions) {
|
|
27
|
-
return options;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function defineSvgrPluginConfig(options: PluginSvgrOptions) {
|
|
31
|
-
return options;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
26
|
export function defineBuildConfig(options: DefineBuildConfigOptions = {}) {
|
|
35
27
|
const {
|
|
36
28
|
entry: entryValue,
|
|
37
|
-
format = "esm",
|
|
38
29
|
syntax = "esnext",
|
|
39
30
|
bundle = false,
|
|
40
31
|
tsconfigPath,
|
|
@@ -48,8 +39,8 @@ export function defineBuildConfig(options: DefineBuildConfigOptions = {}) {
|
|
|
48
39
|
js: "source-map",
|
|
49
40
|
css: true
|
|
50
41
|
},
|
|
51
|
-
react =
|
|
52
|
-
svgr =
|
|
42
|
+
react = false,
|
|
43
|
+
svgr = false,
|
|
53
44
|
transformers = []
|
|
54
45
|
} = options;
|
|
55
46
|
|
|
@@ -65,10 +56,16 @@ export function defineBuildConfig(options: DefineBuildConfigOptions = {}) {
|
|
|
65
56
|
};
|
|
66
57
|
}
|
|
67
58
|
|
|
59
|
+
const svgrDefaultOptions: PluginSvgrOptions = {
|
|
60
|
+
svgrOptions: {
|
|
61
|
+
exportType: "named"
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
68
65
|
const config = defineConfig({
|
|
69
66
|
mode: "production",
|
|
70
67
|
lib: [{
|
|
71
|
-
format,
|
|
68
|
+
format: "esm",
|
|
72
69
|
syntax,
|
|
73
70
|
bundle,
|
|
74
71
|
dts
|
|
@@ -84,15 +81,11 @@ export function defineBuildConfig(options: DefineBuildConfigOptions = {}) {
|
|
|
84
81
|
minify: false,
|
|
85
82
|
sourceMap
|
|
86
83
|
},
|
|
87
|
-
plugins: [
|
|
88
|
-
react && pluginReact(react({})),
|
|
89
|
-
svgr && pluginSvgr(svgr(
|
|
90
|
-
svgrOptions: {
|
|
91
|
-
exportType: "named"
|
|
92
|
-
}
|
|
93
|
-
})),
|
|
84
|
+
plugins: ([
|
|
85
|
+
react && pluginReact(isFunction(react) ? react({}) : {}),
|
|
86
|
+
svgr && pluginSvgr(isFunction(svgr) ? svgr(svgrDefaultOptions) : svgrDefaultOptions),
|
|
94
87
|
...plugins
|
|
95
|
-
].filter(Boolean)
|
|
88
|
+
] as RsbuildPlugins).filter(Boolean)
|
|
96
89
|
});
|
|
97
90
|
|
|
98
91
|
const transformedConfig = applyTransformers(config, transformers, {
|
package/src/dev.ts
CHANGED
|
@@ -3,13 +3,13 @@ import { pluginReact, type PluginReactOptions } from "@rsbuild/plugin-react";
|
|
|
3
3
|
import { pluginSvgr, type PluginSvgrOptions } from "@rsbuild/plugin-svgr";
|
|
4
4
|
import { defineConfig, type Dts, type RsbuildConfigEntry, type RsbuildConfigOutputTarget, type Syntax } from "@rslib/core";
|
|
5
5
|
import { applyTransformers, type RslibConfigTransformer } from "./applyTransformers.ts";
|
|
6
|
+
import { isFunction } from "./assertions.ts";
|
|
6
7
|
|
|
7
8
|
export type DefineDevDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;
|
|
8
9
|
export type DefineDevSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;
|
|
9
10
|
|
|
10
11
|
export interface DefineDevConfigOptions {
|
|
11
12
|
entry?: RsbuildConfigEntry;
|
|
12
|
-
format?: "esm" | "cjs";
|
|
13
13
|
syntax?: Syntax;
|
|
14
14
|
bundle?: boolean;
|
|
15
15
|
tsconfigPath?: string;
|
|
@@ -18,23 +18,14 @@ export interface DefineDevConfigOptions {
|
|
|
18
18
|
distPath?: DistPathConfig;
|
|
19
19
|
plugins?: RsbuildPlugins;
|
|
20
20
|
sourceMap?: boolean | SourceMap;
|
|
21
|
-
react?:
|
|
22
|
-
svgr? :
|
|
21
|
+
react?: true | DefineDevDefineReactPluginConfigFunction;
|
|
22
|
+
svgr? : true | DefineDevSvgrPluginConfigFunction;
|
|
23
23
|
transformers?: RslibConfigTransformer[];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function defaultDefineReactPluginConfig(options: PluginReactOptions) {
|
|
27
|
-
return options;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function defineSvgrPluginConfig(options: PluginSvgrOptions) {
|
|
31
|
-
return options;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
26
|
export function defineDevConfig(options: DefineDevConfigOptions = {}) {
|
|
35
27
|
const {
|
|
36
28
|
entry: entryValue,
|
|
37
|
-
format = "esm",
|
|
38
29
|
syntax = "esnext",
|
|
39
30
|
bundle = false,
|
|
40
31
|
tsconfigPath,
|
|
@@ -48,8 +39,8 @@ export function defineDevConfig(options: DefineDevConfigOptions = {}) {
|
|
|
48
39
|
js: "cheap-module-source-map",
|
|
49
40
|
css: true
|
|
50
41
|
},
|
|
51
|
-
react =
|
|
52
|
-
svgr =
|
|
42
|
+
react = false,
|
|
43
|
+
svgr = false,
|
|
53
44
|
transformers = []
|
|
54
45
|
} = options;
|
|
55
46
|
|
|
@@ -65,10 +56,16 @@ export function defineDevConfig(options: DefineDevConfigOptions = {}) {
|
|
|
65
56
|
};
|
|
66
57
|
}
|
|
67
58
|
|
|
59
|
+
const svgrDefaultOptions: PluginSvgrOptions = {
|
|
60
|
+
svgrOptions: {
|
|
61
|
+
exportType: "named"
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
68
65
|
const config = defineConfig({
|
|
69
66
|
mode: "development",
|
|
70
67
|
lib: [{
|
|
71
|
-
format,
|
|
68
|
+
format: "esm",
|
|
72
69
|
syntax,
|
|
73
70
|
bundle,
|
|
74
71
|
dts
|
|
@@ -84,15 +81,11 @@ export function defineDevConfig(options: DefineDevConfigOptions = {}) {
|
|
|
84
81
|
minify: false,
|
|
85
82
|
sourceMap
|
|
86
83
|
},
|
|
87
|
-
plugins: [
|
|
88
|
-
react && pluginReact(react({})),
|
|
89
|
-
svgr && pluginSvgr(svgr(
|
|
90
|
-
svgrOptions: {
|
|
91
|
-
exportType: "named"
|
|
92
|
-
}
|
|
93
|
-
})),
|
|
84
|
+
plugins: ([
|
|
85
|
+
react && pluginReact(isFunction(react) ? react({}) : {}),
|
|
86
|
+
svgr && pluginSvgr(isFunction(svgr) ? svgr(svgrDefaultOptions) : svgrDefaultOptions),
|
|
94
87
|
...plugins
|
|
95
|
-
]
|
|
88
|
+
] as RsbuildPlugins).filter(Boolean)
|
|
96
89
|
});
|
|
97
90
|
|
|
98
91
|
const transformedConfig = applyTransformers(config, transformers, {
|