@rsbuild/plugin-styled-components 1.0.1 → 1.1.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.
- package/dist/index.cjs +96 -90
- package/dist/index.d.ts +5 -8
- package/dist/index.js +55 -61
- package/package.json +25 -23
- package/dist/index.d.cts +0 -22
package/dist/index.cjs
CHANGED
|
@@ -1,97 +1,103 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
// The require scope
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
/************************************************************************/ // webpack/runtime/define_property_getters
|
|
5
|
+
(()=>{
|
|
6
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
7
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: definition[key]
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
// webpack/runtime/has_own_property
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.o = function(obj, prop) {
|
|
16
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
// webpack/runtime/make_namespace_object
|
|
20
|
+
(()=>{
|
|
21
|
+
// define __esModule on exports
|
|
22
|
+
__webpack_require__.r = function(exports1) {
|
|
23
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
24
|
+
value: 'Module'
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
27
|
+
value: true
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
31
|
+
/************************************************************************/ var __webpack_exports__ = {};
|
|
32
|
+
// ESM COMPAT FLAG
|
|
33
|
+
__webpack_require__.r(__webpack_exports__);
|
|
34
|
+
// EXPORTS
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
PLUGIN_STYLED_COMPONENTS_NAME: ()=>/* binding */ PLUGIN_STYLED_COMPONENTS_NAME,
|
|
37
|
+
pluginStyledComponents: ()=>/* binding */ pluginStyledComponents
|
|
25
38
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// src/index.ts
|
|
33
|
-
var import_node_module = require("module");
|
|
34
|
-
var import_reduce_configs = require("reduce-configs");
|
|
35
|
-
var require2 = (0, import_node_module.createRequire)(importMetaUrl);
|
|
39
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
40
|
+
const external_reduce_configs_namespaceObject = require("reduce-configs");
|
|
41
|
+
const src_require = (0, external_node_module_namespaceObject.createRequire)(/*#__PURE__*/ function() {
|
|
42
|
+
return 'undefined' == typeof document ? new (module.require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
43
|
+
}());
|
|
36
44
|
function isServerTarget(target) {
|
|
37
|
-
|
|
45
|
+
return Array.isArray(target) ? target.includes('node') : 'node' === target;
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
47
|
+
const getDefaultStyledComponentsConfig = (isProd, ssr)=>({
|
|
48
|
+
ssr,
|
|
49
|
+
// "pure" is used to improve dead code elimination in production.
|
|
50
|
+
// we don't need to enable it in development because it will slow down the build process.
|
|
51
|
+
pure: isProd,
|
|
52
|
+
displayName: true,
|
|
53
|
+
transpileTemplateLiterals: true
|
|
54
|
+
});
|
|
55
|
+
const PLUGIN_STYLED_COMPONENTS_NAME = 'rsbuild:styled-components';
|
|
56
|
+
const pluginStyledComponents = (pluginOptions = {})=>({
|
|
57
|
+
name: PLUGIN_STYLED_COMPONENTS_NAME,
|
|
58
|
+
setup (api) {
|
|
59
|
+
if ('webpack' === api.context.bundlerType) return;
|
|
60
|
+
const getMergedOptions = (useSSR, config)=>{
|
|
61
|
+
const isProd = 'production' === config.mode;
|
|
62
|
+
return (0, external_reduce_configs_namespaceObject.reduceConfigs)({
|
|
63
|
+
initial: getDefaultStyledComponentsConfig(isProd, useSSR),
|
|
64
|
+
config: pluginOptions
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
api.modifyEnvironmentConfig((userConfig, { mergeEnvironmentConfig })=>{
|
|
68
|
+
var _userConfig_output;
|
|
69
|
+
const rsbuildConfig = api.getRsbuildConfig();
|
|
70
|
+
const targets = rsbuildConfig.environments ? Object.values(rsbuildConfig.environments).map((e)=>{
|
|
71
|
+
var _e_output, _userConfig_output;
|
|
72
|
+
return (null === (_e_output = e.output) || void 0 === _e_output ? void 0 : _e_output.target) || (null === (_userConfig_output = userConfig.output) || void 0 === _userConfig_output ? void 0 : _userConfig_output.target) || 'web';
|
|
73
|
+
}) : [
|
|
74
|
+
(null === (_userConfig_output = userConfig.output) || void 0 === _userConfig_output ? void 0 : _userConfig_output.target) || 'web'
|
|
75
|
+
];
|
|
76
|
+
const useSSR = isServerTarget(targets);
|
|
77
|
+
const mergedOptions = getMergedOptions(useSSR, userConfig);
|
|
78
|
+
if (!mergedOptions) return userConfig;
|
|
79
|
+
const extraConfig = {
|
|
80
|
+
tools: {
|
|
81
|
+
swc: {
|
|
82
|
+
jsc: {
|
|
83
|
+
experimental: {
|
|
84
|
+
plugins: [
|
|
85
|
+
[
|
|
86
|
+
src_require.resolve('@swc/plugin-styled-components'),
|
|
87
|
+
mergedOptions
|
|
88
|
+
]
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return mergeEnvironmentConfig(extraConfig, userConfig);
|
|
96
|
+
});
|
|
87
97
|
}
|
|
88
|
-
};
|
|
89
|
-
return mergeEnvironmentConfig(extraConfig, userConfig);
|
|
90
98
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
PLUGIN_STYLED_COMPONENTS_NAME,
|
|
96
|
-
pluginStyledComponents
|
|
99
|
+
var __webpack_export_target__ = exports;
|
|
100
|
+
for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
|
|
101
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
102
|
+
value: true
|
|
97
103
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
import { ConfigChain } from 'reduce-configs';
|
|
3
|
-
|
|
1
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
+
import { type ConfigChain } from 'reduce-configs';
|
|
4
3
|
/**
|
|
5
4
|
* The options of [@swc/plugin-styled-components](https://www.npmjs.com/package/@swc/plugin-styled-components).
|
|
6
5
|
*/
|
|
7
|
-
type PluginStyledComponentsOptions = {
|
|
6
|
+
export type PluginStyledComponentsOptions = {
|
|
8
7
|
displayName?: boolean;
|
|
9
8
|
ssr?: boolean;
|
|
10
9
|
fileName?: boolean;
|
|
@@ -16,7 +15,5 @@ type PluginStyledComponentsOptions = {
|
|
|
16
15
|
pure?: boolean;
|
|
17
16
|
cssProps?: boolean;
|
|
18
17
|
};
|
|
19
|
-
declare const PLUGIN_STYLED_COMPONENTS_NAME = "rsbuild:styled-components";
|
|
20
|
-
declare const pluginStyledComponents: (pluginOptions?: ConfigChain<PluginStyledComponentsOptions>) => RsbuildPlugin;
|
|
21
|
-
|
|
22
|
-
export { PLUGIN_STYLED_COMPONENTS_NAME, type PluginStyledComponentsOptions, pluginStyledComponents };
|
|
18
|
+
export declare const PLUGIN_STYLED_COMPONENTS_NAME = "rsbuild:styled-components";
|
|
19
|
+
export declare const pluginStyledComponents: (pluginOptions?: ConfigChain<PluginStyledComponentsOptions>) => RsbuildPlugin;
|
package/dist/index.js
CHANGED
|
@@ -1,65 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
var require2 = createRequire(import.meta.url);
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_module__ from "node:module";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_reduce_configs__ from "reduce-configs";
|
|
3
|
+
const src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url);
|
|
5
4
|
function isServerTarget(target) {
|
|
6
|
-
|
|
5
|
+
return Array.isArray(target) ? target.includes('node') : 'node' === target;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
7
|
+
const getDefaultStyledComponentsConfig = (isProd, ssr)=>({
|
|
8
|
+
ssr,
|
|
9
|
+
// "pure" is used to improve dead code elimination in production.
|
|
10
|
+
// we don't need to enable it in development because it will slow down the build process.
|
|
11
|
+
pure: isProd,
|
|
12
|
+
displayName: true,
|
|
13
|
+
transpileTemplateLiterals: true
|
|
14
|
+
});
|
|
15
|
+
const PLUGIN_STYLED_COMPONENTS_NAME = 'rsbuild:styled-components';
|
|
16
|
+
const pluginStyledComponents = (pluginOptions = {})=>({
|
|
17
|
+
name: PLUGIN_STYLED_COMPONENTS_NAME,
|
|
18
|
+
setup (api) {
|
|
19
|
+
if ('webpack' === api.context.bundlerType) return;
|
|
20
|
+
const getMergedOptions = (useSSR, config)=>{
|
|
21
|
+
const isProd = 'production' === config.mode;
|
|
22
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_reduce_configs__.reduceConfigs)({
|
|
23
|
+
initial: getDefaultStyledComponentsConfig(isProd, useSSR),
|
|
24
|
+
config: pluginOptions
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
api.modifyEnvironmentConfig((userConfig, { mergeEnvironmentConfig })=>{
|
|
28
|
+
var _userConfig_output;
|
|
29
|
+
const rsbuildConfig = api.getRsbuildConfig();
|
|
30
|
+
const targets = rsbuildConfig.environments ? Object.values(rsbuildConfig.environments).map((e)=>{
|
|
31
|
+
var _e_output, _userConfig_output;
|
|
32
|
+
return (null === (_e_output = e.output) || void 0 === _e_output ? void 0 : _e_output.target) || (null === (_userConfig_output = userConfig.output) || void 0 === _userConfig_output ? void 0 : _userConfig_output.target) || 'web';
|
|
33
|
+
}) : [
|
|
34
|
+
(null === (_userConfig_output = userConfig.output) || void 0 === _userConfig_output ? void 0 : _userConfig_output.target) || 'web'
|
|
35
|
+
];
|
|
36
|
+
const useSSR = isServerTarget(targets);
|
|
37
|
+
const mergedOptions = getMergedOptions(useSSR, userConfig);
|
|
38
|
+
if (!mergedOptions) return userConfig;
|
|
39
|
+
const extraConfig = {
|
|
40
|
+
tools: {
|
|
41
|
+
swc: {
|
|
42
|
+
jsc: {
|
|
43
|
+
experimental: {
|
|
44
|
+
plugins: [
|
|
45
|
+
[
|
|
46
|
+
src_require.resolve('@swc/plugin-styled-components'),
|
|
47
|
+
mergedOptions
|
|
48
|
+
]
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return mergeEnvironmentConfig(extraConfig, userConfig);
|
|
56
|
+
});
|
|
56
57
|
}
|
|
57
|
-
};
|
|
58
|
-
return mergeEnvironmentConfig(extraConfig, userConfig);
|
|
59
58
|
});
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
export {
|
|
63
|
-
PLUGIN_STYLED_COMPONENTS_NAME,
|
|
64
|
-
pluginStyledComponents
|
|
65
|
-
};
|
|
59
|
+
export { PLUGIN_STYLED_COMPONENTS_NAME, pluginStyledComponents };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-styled-components",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"repository": "https://github.com/rspack-contrib/rsbuild-plugin-styled-components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,9 +14,16 @@
|
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"module": "./dist/index.mjs",
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
|
-
"files": [
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
"files": ["dist"],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rslib build",
|
|
20
|
+
"dev": "rslib build --watch",
|
|
21
|
+
"lint": "biome check .",
|
|
22
|
+
"lint:write": "biome check . --write",
|
|
23
|
+
"prepare": "simple-git-hooks && npm run build",
|
|
24
|
+
"test": "playwright test",
|
|
25
|
+
"bump": "npx bumpp"
|
|
26
|
+
},
|
|
20
27
|
"simple-git-hooks": {
|
|
21
28
|
"pre-commit": "npx nano-staged"
|
|
22
29
|
},
|
|
@@ -26,38 +33,33 @@
|
|
|
26
33
|
]
|
|
27
34
|
},
|
|
28
35
|
"dependencies": {
|
|
29
|
-
"@swc/plugin-styled-components": "
|
|
36
|
+
"@swc/plugin-styled-components": "5.0.0",
|
|
30
37
|
"reduce-configs": "^1.0.0"
|
|
31
38
|
},
|
|
32
39
|
"devDependencies": {
|
|
33
|
-
"@biomejs/biome": "^1.
|
|
34
|
-
"@playwright/test": "^1.
|
|
35
|
-
"@rsbuild/core": "^1.
|
|
36
|
-
"@
|
|
40
|
+
"@biomejs/biome": "^1.9.4",
|
|
41
|
+
"@playwright/test": "^1.48.2",
|
|
42
|
+
"@rsbuild/core": "^1.1.0",
|
|
43
|
+
"@rslib/core": "^0.0.16",
|
|
44
|
+
"@types/node": "^20.17.6",
|
|
37
45
|
"nano-staged": "^0.8.0",
|
|
38
|
-
"playwright": "^1.
|
|
46
|
+
"playwright": "^1.48.2",
|
|
39
47
|
"simple-git-hooks": "^2.11.1",
|
|
40
|
-
"styled-components": "^6.1.
|
|
41
|
-
"
|
|
42
|
-
"typescript": "^5.5.4"
|
|
48
|
+
"styled-components": "^6.1.13",
|
|
49
|
+
"typescript": "^5.6.3"
|
|
43
50
|
},
|
|
44
51
|
"peerDependencies": {
|
|
45
|
-
"@rsbuild/core": "1.x
|
|
52
|
+
"@rsbuild/core": "1.x"
|
|
46
53
|
},
|
|
47
54
|
"peerDependenciesMeta": {
|
|
48
55
|
"@rsbuild/core": {
|
|
49
56
|
"optional": true
|
|
50
57
|
}
|
|
51
58
|
},
|
|
59
|
+
"packageManager": "pnpm@9.12.3",
|
|
52
60
|
"publishConfig": {
|
|
53
61
|
"access": "public",
|
|
54
|
-
"registry": "https://registry.npmjs.org/"
|
|
55
|
-
|
|
56
|
-
"scripts": {
|
|
57
|
-
"build": "tsup",
|
|
58
|
-
"dev": "tsup --watch",
|
|
59
|
-
"lint": "biome check .",
|
|
60
|
-
"lint:write": "biome check . --write",
|
|
61
|
-
"test": "playwright test"
|
|
62
|
+
"registry": "https://registry.npmjs.org/",
|
|
63
|
+
"provenance": true
|
|
62
64
|
}
|
|
63
|
-
}
|
|
65
|
+
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
import { ConfigChain } from 'reduce-configs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The options of [@swc/plugin-styled-components](https://www.npmjs.com/package/@swc/plugin-styled-components).
|
|
6
|
-
*/
|
|
7
|
-
type PluginStyledComponentsOptions = {
|
|
8
|
-
displayName?: boolean;
|
|
9
|
-
ssr?: boolean;
|
|
10
|
-
fileName?: boolean;
|
|
11
|
-
meaninglessFileNames?: string[];
|
|
12
|
-
namespace?: string;
|
|
13
|
-
topLevelImportPaths?: string[];
|
|
14
|
-
transpileTemplateLiterals?: boolean;
|
|
15
|
-
minify?: boolean;
|
|
16
|
-
pure?: boolean;
|
|
17
|
-
cssProps?: boolean;
|
|
18
|
-
};
|
|
19
|
-
declare const PLUGIN_STYLED_COMPONENTS_NAME = "rsbuild:styled-components";
|
|
20
|
-
declare const pluginStyledComponents: (pluginOptions?: ConfigChain<PluginStyledComponentsOptions>) => RsbuildPlugin;
|
|
21
|
-
|
|
22
|
-
export { PLUGIN_STYLED_COMPONENTS_NAME, type PluginStyledComponentsOptions, pluginStyledComponents };
|