@rsbuild/plugin-svelte 1.0.10 → 1.0.12
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 +2 -2
- package/dist/index.cjs +7 -7
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -12
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -7,12 +7,12 @@ An Rsbuild plugin to provide support for Svelte.
|
|
|
7
7
|
<img src="https://img.shields.io/npm/v/@rsbuild/plugin-svelte?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
|
|
8
8
|
</a>
|
|
9
9
|
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
|
|
10
|
-
<a href="https://npmcharts.com/compare/@rsbuild/plugin-svelte
|
|
10
|
+
<a href="https://npmcharts.com/compare/@rsbuild/plugin-svelte"><img src="https://img.shields.io/npm/dm/@rsbuild/plugin-svelte.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
## Documentation
|
|
14
14
|
|
|
15
|
-
See [Documentation](https://rsbuild.
|
|
15
|
+
See [Documentation](https://rsbuild.rs/plugins/list/plugin-svelte).
|
|
16
16
|
|
|
17
17
|
## License
|
|
18
18
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
const __rslib_import_meta_url__ = "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
var __webpack_require__ = {};
|
|
4
4
|
__webpack_require__.n = (module)=>{
|
|
5
5
|
var getter = module && module.__esModule ? ()=>module.default : ()=>module;
|
|
@@ -12,7 +12,7 @@ __webpack_require__.n = (module)=>{
|
|
|
12
12
|
get: definition[key]
|
|
13
13
|
});
|
|
14
14
|
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
|
|
15
|
-
|
|
15
|
+
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
16
16
|
value: 'Module'
|
|
17
17
|
}), Object.defineProperty(exports1, '__esModule', {
|
|
18
18
|
value: !0
|
|
@@ -23,13 +23,13 @@ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_expo
|
|
|
23
23
|
PLUGIN_SVELTE_NAME: ()=>PLUGIN_SVELTE_NAME,
|
|
24
24
|
pluginSvelte: ()=>pluginSvelte
|
|
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
|
-
|
|
28
|
+
const core_namespaceObject = require("@rsbuild/core"), 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.');
|
|
32
|
-
} catch
|
|
32
|
+
} catch {
|
|
33
33
|
return !1;
|
|
34
34
|
}
|
|
35
35
|
};
|
|
@@ -78,10 +78,10 @@ function pluginSvelte(options = {}) {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
for(var
|
|
81
|
+
for(var __rspack_i in exports.PLUGIN_SVELTE_NAME = __webpack_exports__.PLUGIN_SVELTE_NAME, exports.pluginSvelte = __webpack_exports__.pluginSvelte, __webpack_exports__)-1 === [
|
|
82
82
|
"PLUGIN_SVELTE_NAME",
|
|
83
83
|
"pluginSvelte"
|
|
84
|
-
].indexOf(
|
|
84
|
+
].indexOf(__rspack_i) && (exports[__rspack_i] = __webpack_exports__[__rspack_i]);
|
|
85
85
|
Object.defineProperty(exports, '__esModule', {
|
|
86
86
|
value: !0
|
|
87
87
|
});
|
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'>;
|
|
@@ -11,9 +11,9 @@ export interface SvelteLoaderOptions {
|
|
|
11
11
|
hotOptions?: {
|
|
12
12
|
/** Preserve local component state */
|
|
13
13
|
preserveLocalState?: boolean;
|
|
14
|
-
[key: string]:
|
|
14
|
+
[key: string]: unknown;
|
|
15
15
|
};
|
|
16
|
-
[key: string]:
|
|
16
|
+
[key: string]: unknown;
|
|
17
17
|
}
|
|
18
18
|
export type PluginSvelteOptions = {
|
|
19
19
|
/**
|
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.12",
|
|
4
4
|
"description": "Svelte plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,23 +26,23 @@
|
|
|
26
26
|
"svelte-preprocess": "^6.0.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@rslib/core": "0.
|
|
30
|
-
"@types/node": "^
|
|
31
|
-
"svelte": "^5.
|
|
32
|
-
"typescript": "^5.
|
|
33
|
-
"@rsbuild/core": "1.
|
|
29
|
+
"@rslib/core": "0.19.1",
|
|
30
|
+
"@types/node": "^24.10.4",
|
|
31
|
+
"svelte": "^5.46.1",
|
|
32
|
+
"typescript": "^5.9.3",
|
|
33
|
+
"@rsbuild/core": "1.7.2",
|
|
34
34
|
"@scripts/test-helper": "1.0.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@rsbuild/core": "1.
|
|
37
|
+
"@rsbuild/core": "^1.0.0 || ^2.0.0-0"
|
|
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
|
|
45
|
+
"dev": "rslib build -w",
|
|
46
|
+
"bump": "pnpx bumpp --no-tag"
|
|
47
47
|
}
|
|
48
48
|
}
|