@rsbuild/plugin-svelte 1.0.2 → 1.0.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.
- package/dist/index.cjs +11 -6
- package/dist/index.js +10 -5
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var __webpack_require__ = {};
|
|
4
4
|
/************************************************************************/ // webpack/runtime/compat_get_default_export
|
|
5
5
|
(()=>{
|
|
6
|
-
// getDefaultExport function for compatibility with non-
|
|
6
|
+
// getDefaultExport function for compatibility with non-ESM modules
|
|
7
7
|
__webpack_require__.n = function(module) {
|
|
8
8
|
var getter = module && module.__esModule ? function() {
|
|
9
9
|
return module['default'];
|
|
@@ -67,8 +67,7 @@ const isSvelte5 = async (sveltePath)=>{
|
|
|
67
67
|
return false;
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
-
function pluginSvelte() {
|
|
71
|
-
let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
|
70
|
+
function pluginSvelte(options = {}) {
|
|
72
71
|
return {
|
|
73
72
|
name: PLUGIN_SVELTE_NAME,
|
|
74
73
|
setup (api) {
|
|
@@ -86,8 +85,7 @@ function pluginSvelte() {
|
|
|
86
85
|
cause: err
|
|
87
86
|
});
|
|
88
87
|
}
|
|
89
|
-
api.modifyBundlerChain(async (chain,
|
|
90
|
-
let { CHAIN_ID, environment, isDev, isProd } = param;
|
|
88
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev, isProd })=>{
|
|
91
89
|
const svelte5 = await isSvelte5(sveltePath);
|
|
92
90
|
const environmentConfig = environment.config;
|
|
93
91
|
if (!svelte5) chain.resolve.alias.set('svelte', external_node_path_default().join(sveltePath, 'src/runtime'));
|
|
@@ -120,7 +118,14 @@ function pluginSvelte() {
|
|
|
120
118
|
...userLoaderOptions.compilerOptions
|
|
121
119
|
}
|
|
122
120
|
};
|
|
123
|
-
chain.module.rule(CHAIN_ID.RULE.SVELTE).test(
|
|
121
|
+
chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/).use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions);
|
|
122
|
+
const jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS);
|
|
123
|
+
if (svelte5 && jsRule) {
|
|
124
|
+
const swcUse = jsRule.uses.get(CHAIN_ID.USE.SWC);
|
|
125
|
+
const regexp = /\.(?:svelte\.js|svelte\.ts)$/;
|
|
126
|
+
jsRule.exclude.add(regexp);
|
|
127
|
+
chain.module.rule('svelte-js').test(regexp).use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions).end().use(CHAIN_ID.USE.SWC).loader(swcUse.get('loader')).options(swcUse.get('options'));
|
|
128
|
+
}
|
|
124
129
|
});
|
|
125
130
|
}
|
|
126
131
|
};
|
package/dist/index.js
CHANGED
|
@@ -13,8 +13,7 @@ const isSvelte5 = async (sveltePath)=>{
|
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
function pluginSvelte() {
|
|
17
|
-
let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
|
16
|
+
function pluginSvelte(options = {}) {
|
|
18
17
|
return {
|
|
19
18
|
name: PLUGIN_SVELTE_NAME,
|
|
20
19
|
setup (api) {
|
|
@@ -32,8 +31,7 @@ function pluginSvelte() {
|
|
|
32
31
|
cause: err
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
|
-
api.modifyBundlerChain(async (chain,
|
|
36
|
-
let { CHAIN_ID, environment, isDev, isProd } = param;
|
|
34
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev, isProd })=>{
|
|
37
35
|
const svelte5 = await isSvelte5(sveltePath);
|
|
38
36
|
const environmentConfig = environment.config;
|
|
39
37
|
if (!svelte5) chain.resolve.alias.set('svelte', __WEBPACK_EXTERNAL_MODULE_node_path__["default"].join(sveltePath, 'src/runtime'));
|
|
@@ -66,7 +64,14 @@ function pluginSvelte() {
|
|
|
66
64
|
...userLoaderOptions.compilerOptions
|
|
67
65
|
}
|
|
68
66
|
};
|
|
69
|
-
chain.module.rule(CHAIN_ID.RULE.SVELTE).test(
|
|
67
|
+
chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/).use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions);
|
|
68
|
+
const jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS);
|
|
69
|
+
if (svelte5 && jsRule) {
|
|
70
|
+
const swcUse = jsRule.uses.get(CHAIN_ID.USE.SWC);
|
|
71
|
+
const regexp = /\.(?:svelte\.js|svelte\.ts)$/;
|
|
72
|
+
jsRule.exclude.add(regexp);
|
|
73
|
+
chain.module.rule('svelte-js').test(regexp).use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions).end().use(CHAIN_ID.USE.SWC).loader(swcUse.get('loader')).options(swcUse.get('options'));
|
|
74
|
+
}
|
|
70
75
|
});
|
|
71
76
|
}
|
|
72
77
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-svelte",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Svelte plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "18.x",
|
|
30
|
-
"svelte": "^
|
|
30
|
+
"svelte": "^5.1.10",
|
|
31
31
|
"typescript": "^5.6.3",
|
|
32
|
-
"@rsbuild/core": "1.0
|
|
32
|
+
"@rsbuild/core": "1.1.0",
|
|
33
33
|
"@scripts/test-helper": "1.0.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@rsbuild/core": "1.x
|
|
36
|
+
"@rsbuild/core": "1.x"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public",
|