@rsbuild/plugin-svelte 1.0.12 → 1.1.1
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 +3 -3
- package/dist/index.js +2 -3
- package/package.json +13 -7
package/dist/index.cjs
CHANGED
|
@@ -25,7 +25,7 @@ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_expo
|
|
|
25
25
|
});
|
|
26
26
|
const external_node_fs_namespaceObject = require("node:fs"), external_node_module_namespaceObject = require("node:module"), external_node_path_namespaceObject = require("node:path");
|
|
27
27
|
var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
|
|
28
|
-
const
|
|
28
|
+
const external_svelte_preprocess_namespaceObject = require("svelte-preprocess"), src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), PLUGIN_SVELTE_NAME = 'rsbuild:svelte', isSvelte5 = async (sveltePath)=>{
|
|
29
29
|
try {
|
|
30
30
|
let pkgPath = external_node_path_default().join(sveltePath, 'package.json'), pkgRaw = await external_node_fs_namespaceObject.promises.readFile(pkgPath, 'utf-8');
|
|
31
31
|
return JSON.parse(pkgRaw).version.startsWith('5.');
|
|
@@ -45,7 +45,7 @@ function pluginSvelte(options = {}) {
|
|
|
45
45
|
]
|
|
46
46
|
}));
|
|
47
47
|
} catch (err) {
|
|
48
|
-
throw
|
|
48
|
+
throw api.logger.error('Cannot resolve `svelte` package under the project directory, did you forget to install it?'), Error('[rsbuild:svelte] Failed to resolve `svelte` package', {
|
|
49
49
|
cause: err
|
|
50
50
|
});
|
|
51
51
|
}
|
|
@@ -69,7 +69,7 @@ function pluginSvelte(options = {}) {
|
|
|
69
69
|
dev: isDev,
|
|
70
70
|
...userLoaderOptions.compilerOptions
|
|
71
71
|
}
|
|
72
|
-
}, jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS), swcUse = jsRule.uses.get(CHAIN_ID.USE.SWC), svelteRule = chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/);
|
|
72
|
+
}, isV1 = api.context.version.startsWith('1.'), jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS), swcUse = (isV1 ? jsRule : jsRule.oneOfs.get(CHAIN_ID.ONE_OF.JS_MAIN)).uses.get(CHAIN_ID.USE.SWC), svelteRule = chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/);
|
|
73
73
|
if (svelte5 && jsRule && svelteRule.use(CHAIN_ID.USE.SWC).loader(swcUse.get('loader')).options(swcUse.get('options')), svelteRule.use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions).end(), svelte5 && jsRule) {
|
|
74
74
|
let regexp = /\.(?:svelte\.js|svelte\.ts)$/;
|
|
75
75
|
jsRule.exclude.add(regexp), 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'));
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { promises } from "node:fs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import node_path from "node:path";
|
|
4
|
-
import { logger } from "@rsbuild/core";
|
|
5
4
|
import { sveltePreprocess } from "svelte-preprocess";
|
|
6
5
|
let src_require = createRequire(import.meta.url), PLUGIN_SVELTE_NAME = 'rsbuild:svelte', isSvelte5 = async (sveltePath)=>{
|
|
7
6
|
try {
|
|
@@ -23,7 +22,7 @@ function pluginSvelte(options = {}) {
|
|
|
23
22
|
]
|
|
24
23
|
}));
|
|
25
24
|
} catch (err) {
|
|
26
|
-
throw logger.error('Cannot resolve `svelte` package under the project directory, did you forget to install it?'), Error('[rsbuild:svelte] Failed to resolve `svelte` package', {
|
|
25
|
+
throw api.logger.error('Cannot resolve `svelte` package under the project directory, did you forget to install it?'), Error('[rsbuild:svelte] Failed to resolve `svelte` package', {
|
|
27
26
|
cause: err
|
|
28
27
|
});
|
|
29
28
|
}
|
|
@@ -47,7 +46,7 @@ function pluginSvelte(options = {}) {
|
|
|
47
46
|
dev: isDev,
|
|
48
47
|
...userLoaderOptions.compilerOptions
|
|
49
48
|
}
|
|
50
|
-
}, jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS), swcUse = jsRule.uses.get(CHAIN_ID.USE.SWC), svelteRule = chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/);
|
|
49
|
+
}, isV1 = api.context.version.startsWith('1.'), jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS), swcUse = (isV1 ? jsRule : jsRule.oneOfs.get(CHAIN_ID.ONE_OF.JS_MAIN)).uses.get(CHAIN_ID.USE.SWC), svelteRule = chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/);
|
|
51
50
|
if (svelte5 && jsRule && svelteRule.use(CHAIN_ID.USE.SWC).loader(swcUse.get('loader')).options(swcUse.get('options')), svelteRule.use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions).end(), svelte5 && jsRule) {
|
|
52
51
|
let regexp = /\.(?:svelte\.js|svelte\.ts)$/;
|
|
53
52
|
jsRule.exclude.add(regexp), 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'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-svelte",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Svelte plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,15 +26,21 @@
|
|
|
26
26
|
"svelte-preprocess": "^6.0.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
29
|
+
"@rsbuild/core-v1": "npm:@rsbuild/core@^1.7.3",
|
|
30
|
+
"@rslib/core": "0.20.0",
|
|
31
|
+
"@types/node": "^24.12.0",
|
|
32
|
+
"svelte": "^5.53.7",
|
|
32
33
|
"typescript": "^5.9.3",
|
|
33
|
-
"@rsbuild/core": "
|
|
34
|
-
"@scripts/test-helper": "1.0.
|
|
34
|
+
"@rsbuild/core": "2.0.0-beta.8",
|
|
35
|
+
"@scripts/test-helper": "1.0.0"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"@rsbuild/core": "^1.
|
|
38
|
+
"@rsbuild/core": "^1.4.0 || ^2.0.0-0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependenciesMeta": {
|
|
41
|
+
"@rsbuild/core": {
|
|
42
|
+
"optional": true
|
|
43
|
+
}
|
|
38
44
|
},
|
|
39
45
|
"publishConfig": {
|
|
40
46
|
"access": "public",
|