@rsbuild/plugin-svelte 0.0.17 → 0.0.19
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.d.ts +12 -9
- package/dist/index.js +3 -1
- package/dist/index.mjs +70 -0
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { RsbuildPlugin, RsbuildPluginAPI } from '@rsbuild/core';
|
|
2
|
+
|
|
3
|
+
type PluginSvelteOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* The options of svelte-loader
|
|
6
|
+
*
|
|
7
|
+
* See https://github.com/sveltejs/svelte-loader
|
|
8
|
+
*/
|
|
9
|
+
svelteLoaderOptions?: Record<string, any>;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
+
declare function pluginSvelte(options?: PluginSvelteOptions): RsbuildPlugin<RsbuildPluginAPI>;
|
|
12
|
+
|
|
13
|
+
export { PluginSvelteOptions, pluginSvelte };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
29
31
|
var src_exports = {};
|
|
30
32
|
__export(src_exports, {
|
|
31
33
|
pluginSvelte: () => pluginSvelte
|
|
@@ -55,7 +57,7 @@ function pluginSvelte(options = {}) {
|
|
|
55
57
|
}
|
|
56
58
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd }) => {
|
|
57
59
|
var _a;
|
|
58
|
-
const { default: sveltePreprocess } = await
|
|
60
|
+
const { default: sveltePreprocess } = await import("svelte-preprocess");
|
|
59
61
|
const rsbuildConfig = api.getNormalizedConfig();
|
|
60
62
|
chain.resolve.alias.set("svelte", import_path.default.join(sveltePath, "src/runtime")).end().extensions.add(".svelte").end().mainFields.prepend("svelte").end().set("conditionNames", ["svelte", "browser", "import"]);
|
|
61
63
|
const loaderPath = require.resolve("svelte-loader");
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.40.0_typescript@5.2.2/node_modules/@modern-js/module-tools/shims/esm.js
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
|
+
import path from "path";
|
|
12
|
+
|
|
13
|
+
// ../../scripts/require_shims.js
|
|
14
|
+
import { createRequire } from "module";
|
|
15
|
+
global.require = createRequire(import.meta.url);
|
|
16
|
+
|
|
17
|
+
// src/index.ts
|
|
18
|
+
import path2 from "path";
|
|
19
|
+
import { logger } from "@rsbuild/shared";
|
|
20
|
+
import { deepmerge } from "@rsbuild/shared/deepmerge";
|
|
21
|
+
function pluginSvelte(options = {}) {
|
|
22
|
+
return {
|
|
23
|
+
name: "plugin-svelte",
|
|
24
|
+
setup(api) {
|
|
25
|
+
let sveltePath = "";
|
|
26
|
+
try {
|
|
27
|
+
sveltePath = path2.dirname(
|
|
28
|
+
__require.resolve("svelte/package.json", {
|
|
29
|
+
paths: [api.context.rootPath]
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
logger.error(
|
|
34
|
+
`Cannot resolve \`svelte\` package under the project directory, did you forget to install it?`
|
|
35
|
+
);
|
|
36
|
+
throw new Error(`Cannot resolve \`svelte\` package`, {
|
|
37
|
+
cause: err
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd }) => {
|
|
41
|
+
const { default: sveltePreprocess } = await import("svelte-preprocess");
|
|
42
|
+
const rsbuildConfig = api.getNormalizedConfig();
|
|
43
|
+
chain.resolve.alias.set("svelte", path2.join(sveltePath, "src/runtime")).end().extensions.add(".svelte").end().mainFields.prepend("svelte").end().set("conditionNames", ["svelte", "browser", "import"]);
|
|
44
|
+
const loaderPath = __require.resolve("svelte-loader");
|
|
45
|
+
chain.merge({
|
|
46
|
+
resolveLoader: {
|
|
47
|
+
alias: {
|
|
48
|
+
"svelte-loader": loaderPath
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const svelteLoaderOptions = deepmerge(
|
|
53
|
+
{
|
|
54
|
+
compilerOptions: {
|
|
55
|
+
dev: !isProd
|
|
56
|
+
},
|
|
57
|
+
preprocess: sveltePreprocess(),
|
|
58
|
+
emitCss: !rsbuildConfig.output.disableCssExtract,
|
|
59
|
+
hotReload: !isProd && rsbuildConfig.dev.hmr
|
|
60
|
+
},
|
|
61
|
+
options.svelteLoaderOptions ?? {}
|
|
62
|
+
);
|
|
63
|
+
chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/).use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
pluginSvelte
|
|
70
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "Svelte plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.mjs",
|
|
14
15
|
"default": "./dist/index.js"
|
|
15
16
|
}
|
|
16
17
|
},
|
|
@@ -22,13 +23,13 @@
|
|
|
22
23
|
"dependencies": {
|
|
23
24
|
"svelte-loader": "3.1.9",
|
|
24
25
|
"svelte-preprocess": "^5.0.4",
|
|
25
|
-
"@rsbuild/shared": "0.0.
|
|
26
|
+
"@rsbuild/shared": "0.0.19"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/node": "^16",
|
|
29
30
|
"typescript": "^5.2.2",
|
|
30
|
-
"@rsbuild/
|
|
31
|
-
"@rsbuild/
|
|
31
|
+
"@rsbuild/core": "0.0.19",
|
|
32
|
+
"@rsbuild/test-helper": "0.0.19"
|
|
32
33
|
},
|
|
33
34
|
"publishConfig": {
|
|
34
35
|
"access": "public",
|