@rsbuild/plugin-svelte 0.7.9 → 1.0.0-alpha.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 +33 -26
- package/dist/index.d.ts +8 -11
- package/dist/index.js +34 -27
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -57,34 +57,41 @@ function pluginSvelte(options = {}) {
|
|
|
57
57
|
cause: err
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
api.modifyBundlerChain(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
api.modifyBundlerChain(
|
|
61
|
+
async (chain, { CHAIN_ID, environment, isDev, isProd }) => {
|
|
62
|
+
const { default: sveltePreprocess } = await import("svelte-preprocess");
|
|
63
|
+
const environmentConfig = environment.config;
|
|
64
|
+
chain.resolve.alias.set(
|
|
65
|
+
"svelte",
|
|
66
|
+
import_node_path.default.join(sveltePath, "src/runtime")
|
|
67
|
+
);
|
|
68
|
+
chain.resolve.extensions.add(".svelte");
|
|
69
|
+
chain.resolve.mainFields.add("svelte").add("...");
|
|
70
|
+
chain.resolve.conditionNames.add("svelte").add("...");
|
|
71
|
+
const loaderPath = require.resolve("svelte-loader");
|
|
72
|
+
chain.merge({
|
|
73
|
+
resolveLoader: {
|
|
74
|
+
alias: {
|
|
75
|
+
"svelte-loader": loaderPath
|
|
76
|
+
}
|
|
72
77
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
});
|
|
79
|
+
const svelteLoaderOptions = (0, import_shared.deepmerge)(
|
|
80
|
+
{
|
|
81
|
+
compilerOptions: {
|
|
82
|
+
dev: isDev
|
|
83
|
+
},
|
|
84
|
+
preprocess: sveltePreprocess(options.preprocessOptions),
|
|
85
|
+
// NOTE emitCss: true is currently not supported with HMR
|
|
86
|
+
// See https://github.com/web-infra-dev/rsbuild/issues/2744
|
|
87
|
+
emitCss: isProd && !environmentConfig.output.injectStyles,
|
|
88
|
+
hotReload: isDev && environmentConfig.dev.hmr
|
|
79
89
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
);
|
|
86
|
-
chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/).use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions);
|
|
87
|
-
});
|
|
90
|
+
options.svelteLoaderOptions ?? {}
|
|
91
|
+
);
|
|
92
|
+
chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/).use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions);
|
|
93
|
+
}
|
|
94
|
+
);
|
|
88
95
|
}
|
|
89
96
|
};
|
|
90
97
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface SvelteLoaderOptions {
|
|
1
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
+
import type { sveltePreprocess } from 'svelte-preprocess';
|
|
3
|
+
import type { CompileOptions } from 'svelte/compiler';
|
|
4
|
+
export type AutoPreprocessOptions = NonNullable<Parameters<typeof sveltePreprocess>[0]>;
|
|
5
|
+
export interface SvelteLoaderOptions {
|
|
7
6
|
compilerOptions?: Omit<CompileOptions, 'filename' | 'format' | 'generate'>;
|
|
8
7
|
/**
|
|
9
8
|
* Extra HMR options, the defaults are completely fine\
|
|
@@ -16,7 +15,7 @@ interface SvelteLoaderOptions {
|
|
|
16
15
|
};
|
|
17
16
|
[key: string]: any;
|
|
18
17
|
}
|
|
19
|
-
type PluginSvelteOptions = {
|
|
18
|
+
export type PluginSvelteOptions = {
|
|
20
19
|
/**
|
|
21
20
|
* The options of svelte-loader
|
|
22
21
|
* @see https://github.com/sveltejs/svelte-loader
|
|
@@ -28,7 +27,5 @@ type PluginSvelteOptions = {
|
|
|
28
27
|
*/
|
|
29
28
|
preprocessOptions?: AutoPreprocessOptions;
|
|
30
29
|
};
|
|
31
|
-
declare const PLUGIN_SVELTE_NAME = "rsbuild:svelte";
|
|
32
|
-
declare function pluginSvelte(options?: PluginSvelteOptions): RsbuildPlugin;
|
|
33
|
-
|
|
34
|
-
export { PLUGIN_SVELTE_NAME, type PluginSvelteOptions, type SvelteLoaderOptions, pluginSvelte };
|
|
30
|
+
export declare const PLUGIN_SVELTE_NAME = "rsbuild:svelte";
|
|
31
|
+
export declare function pluginSvelte(options?: PluginSvelteOptions): RsbuildPlugin;
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
9
9
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.
|
|
12
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.54.5_eslint@9.6.0_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js
|
|
13
13
|
import { fileURLToPath } from "url";
|
|
14
14
|
import path from "path";
|
|
15
15
|
|
|
@@ -37,34 +37,41 @@ function pluginSvelte(options = {}) {
|
|
|
37
37
|
cause: err
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
api.modifyBundlerChain(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
api.modifyBundlerChain(
|
|
41
|
+
async (chain, { CHAIN_ID, environment, isDev, isProd }) => {
|
|
42
|
+
const { default: sveltePreprocess } = await import("svelte-preprocess");
|
|
43
|
+
const environmentConfig = environment.config;
|
|
44
|
+
chain.resolve.alias.set(
|
|
45
|
+
"svelte",
|
|
46
|
+
path2.join(sveltePath, "src/runtime")
|
|
47
|
+
);
|
|
48
|
+
chain.resolve.extensions.add(".svelte");
|
|
49
|
+
chain.resolve.mainFields.add("svelte").add("...");
|
|
50
|
+
chain.resolve.conditionNames.add("svelte").add("...");
|
|
51
|
+
const loaderPath = __require.resolve("svelte-loader");
|
|
52
|
+
chain.merge({
|
|
53
|
+
resolveLoader: {
|
|
54
|
+
alias: {
|
|
55
|
+
"svelte-loader": loaderPath
|
|
56
|
+
}
|
|
52
57
|
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
});
|
|
59
|
+
const svelteLoaderOptions = deepmerge(
|
|
60
|
+
{
|
|
61
|
+
compilerOptions: {
|
|
62
|
+
dev: isDev
|
|
63
|
+
},
|
|
64
|
+
preprocess: sveltePreprocess(options.preprocessOptions),
|
|
65
|
+
// NOTE emitCss: true is currently not supported with HMR
|
|
66
|
+
// See https://github.com/web-infra-dev/rsbuild/issues/2744
|
|
67
|
+
emitCss: isProd && !environmentConfig.output.injectStyles,
|
|
68
|
+
hotReload: isDev && environmentConfig.dev.hmr
|
|
59
69
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
);
|
|
66
|
-
chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/).use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions);
|
|
67
|
-
});
|
|
70
|
+
options.svelteLoaderOptions ?? {}
|
|
71
|
+
);
|
|
72
|
+
chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/).use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions);
|
|
73
|
+
}
|
|
74
|
+
);
|
|
68
75
|
}
|
|
69
76
|
};
|
|
70
77
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
4
|
"description": "Svelte plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"svelte-loader": "3.2.3",
|
|
26
|
-
"svelte-preprocess": "^
|
|
27
|
-
"@rsbuild/shared": "0.
|
|
26
|
+
"svelte-preprocess": "^6.0.1",
|
|
27
|
+
"@rsbuild/shared": "1.0.0-alpha.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "18.x",
|
|
31
31
|
"svelte": "^4.2.18",
|
|
32
|
-
"typescript": "^5.
|
|
33
|
-
"@rsbuild/core": "0.
|
|
34
|
-
"@scripts/test-helper": "0.
|
|
32
|
+
"typescript": "^5.5.2",
|
|
33
|
+
"@rsbuild/core": "1.0.0-alpha.0",
|
|
34
|
+
"@scripts/test-helper": "1.0.0-alpha.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@rsbuild/core": "^0.
|
|
37
|
+
"@rsbuild/core": "^1.0.0-alpha.0"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public",
|