@rsbuild/plugin-svelte 1.0.10 → 1.0.11
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/README.md +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -12
- package/package.json +8 -8
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -20,8 +20,8 @@ __webpack_require__.n = (module)=>{
|
|
|
20
20
|
};
|
|
21
21
|
var __webpack_exports__ = {};
|
|
22
22
|
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
pluginSvelte: ()=>pluginSvelte,
|
|
24
|
+
PLUGIN_SVELTE_NAME: ()=>PLUGIN_SVELTE_NAME
|
|
25
25
|
});
|
|
26
26
|
let 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);
|
|
@@ -29,7 +29,7 @@ let core_namespaceObject = require("@rsbuild/core"), external_svelte_preprocess_
|
|
|
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.');
|
|
32
|
-
} catch
|
|
32
|
+
} catch {
|
|
33
33
|
return !1;
|
|
34
34
|
}
|
|
35
35
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
import { sveltePreprocess } from 'svelte-preprocess';
|
|
3
2
|
import type { CompileOptions } from 'svelte/compiler';
|
|
3
|
+
import { sveltePreprocess } from 'svelte-preprocess';
|
|
4
4
|
export type AutoPreprocessOptions = NonNullable<Parameters<typeof sveltePreprocess>[0]>;
|
|
5
5
|
export interface SvelteLoaderOptions {
|
|
6
6
|
compilerOptions?: Omit<CompileOptions, 'filename' | 'format' | 'generate'>;
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
let src_require =
|
|
1
|
+
import { promises } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
import { logger } from "@rsbuild/core";
|
|
5
|
+
import { sveltePreprocess } from "svelte-preprocess";
|
|
6
|
+
let src_require = createRequire(import.meta.url), PLUGIN_SVELTE_NAME = 'rsbuild:svelte', isSvelte5 = async (sveltePath)=>{
|
|
7
7
|
try {
|
|
8
|
-
let pkgPath =
|
|
8
|
+
let pkgPath = node_path.join(sveltePath, 'package.json'), pkgRaw = await promises.readFile(pkgPath, 'utf-8');
|
|
9
9
|
return JSON.parse(pkgRaw).version.startsWith('5.');
|
|
10
|
-
} catch
|
|
10
|
+
} catch {
|
|
11
11
|
return !1;
|
|
12
12
|
}
|
|
13
13
|
};
|
|
@@ -17,13 +17,13 @@ function pluginSvelte(options = {}) {
|
|
|
17
17
|
setup (api) {
|
|
18
18
|
let sveltePath = '';
|
|
19
19
|
try {
|
|
20
|
-
sveltePath =
|
|
20
|
+
sveltePath = node_path.dirname(src_require.resolve('svelte/package.json', {
|
|
21
21
|
paths: [
|
|
22
22
|
api.context.rootPath
|
|
23
23
|
]
|
|
24
24
|
}));
|
|
25
25
|
} catch (err) {
|
|
26
|
-
throw
|
|
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', {
|
|
27
27
|
cause: err
|
|
28
28
|
});
|
|
29
29
|
}
|
|
@@ -35,11 +35,11 @@ function pluginSvelte(options = {}) {
|
|
|
35
35
|
}
|
|
36
36
|
}, config)), api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev, isProd })=>{
|
|
37
37
|
let svelte5 = await isSvelte5(sveltePath), environmentConfig = environment.config;
|
|
38
|
-
svelte5 || chain.resolve.alias.set('svelte',
|
|
38
|
+
svelte5 || chain.resolve.alias.set('svelte', node_path.join(sveltePath, 'src/runtime')), chain.resolve.extensions.add('.svelte'), chain.resolve.mainFields.add('svelte').add('...'), chain.resolve.conditionNames.add('svelte').add('...');
|
|
39
39
|
let loaderPath = src_require.resolve('svelte-loader');
|
|
40
40
|
chain.resolveLoader.alias.set('svelte-loader', loaderPath);
|
|
41
41
|
let userLoaderOptions = options.svelteLoaderOptions ?? {}, svelteLoaderOptions = {
|
|
42
|
-
preprocess:
|
|
42
|
+
preprocess: sveltePreprocess(options.preprocessOptions),
|
|
43
43
|
emitCss: isProd && !environmentConfig.output.injectStyles,
|
|
44
44
|
hotReload: isDev && environmentConfig.dev.hmr,
|
|
45
45
|
...userLoaderOptions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-svelte",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "Svelte plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"svelte-preprocess": "^6.0.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@rslib/core": "0.
|
|
30
|
-
"@types/node": "^22.
|
|
31
|
-
"svelte": "^5.
|
|
32
|
-
"typescript": "^5.
|
|
33
|
-
"@rsbuild/core": "1.
|
|
29
|
+
"@rslib/core": "0.11.1",
|
|
30
|
+
"@types/node": "^22.17.0",
|
|
31
|
+
"svelte": "^5.37.3",
|
|
32
|
+
"typescript": "^5.9.2",
|
|
33
|
+
"@rsbuild/core": "1.4.14",
|
|
34
34
|
"@scripts/test-helper": "1.0.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public",
|
|
41
|
-
"provenance": true,
|
|
42
41
|
"registry": "https://registry.npmjs.org/"
|
|
43
42
|
},
|
|
44
43
|
"scripts": {
|
|
45
44
|
"build": "rslib build",
|
|
46
|
-
"dev": "rslib build --watch"
|
|
45
|
+
"dev": "rslib build --watch",
|
|
46
|
+
"bump": "npx bumpp --no-tag"
|
|
47
47
|
}
|
|
48
48
|
}
|