@rsbuild/plugin-svelte 0.6.14 → 0.7.0-beta.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 +92 -0
- package/dist/index.d.ts +8 -10
- package/dist/index.js +25 -45
- package/package.json +10 -10
- package/dist/index.mjs +0 -72
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
pluginSvelte: () => pluginSvelte
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
var import_node_path = __toESM(require("path"));
|
|
37
|
+
var import_core = require("@rsbuild/core");
|
|
38
|
+
var import_shared = require("@rsbuild/shared");
|
|
39
|
+
function pluginSvelte(options = {}) {
|
|
40
|
+
return {
|
|
41
|
+
name: "rsbuild:svelte",
|
|
42
|
+
setup(api) {
|
|
43
|
+
let sveltePath = "";
|
|
44
|
+
try {
|
|
45
|
+
sveltePath = import_node_path.default.dirname(
|
|
46
|
+
require.resolve("svelte/package.json", {
|
|
47
|
+
paths: [api.context.rootPath]
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
import_core.logger.error(
|
|
52
|
+
"Cannot resolve `svelte` package under the project directory, did you forget to install it?"
|
|
53
|
+
);
|
|
54
|
+
throw new Error("Cannot resolve `svelte` package", {
|
|
55
|
+
cause: err
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev }) => {
|
|
59
|
+
const { default: sveltePreprocess } = await import("svelte-preprocess");
|
|
60
|
+
const rsbuildConfig = api.getNormalizedConfig();
|
|
61
|
+
chain.resolve.alias.set("svelte", import_node_path.default.join(sveltePath, "src/runtime"));
|
|
62
|
+
chain.resolve.extensions.add(".svelte");
|
|
63
|
+
chain.resolve.mainFields.add("svelte").add("...");
|
|
64
|
+
chain.resolve.set("conditionNames", ["svelte", "..."]);
|
|
65
|
+
const loaderPath = require.resolve("svelte-loader");
|
|
66
|
+
chain.merge({
|
|
67
|
+
resolveLoader: {
|
|
68
|
+
alias: {
|
|
69
|
+
"svelte-loader": loaderPath
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const svelteLoaderOptions = (0, import_shared.deepmerge)(
|
|
74
|
+
{
|
|
75
|
+
compilerOptions: {
|
|
76
|
+
dev: isDev
|
|
77
|
+
},
|
|
78
|
+
preprocess: sveltePreprocess(options.preprocessOptions),
|
|
79
|
+
emitCss: !rsbuildConfig.output.injectStyles,
|
|
80
|
+
hotReload: isDev && rsbuildConfig.dev.hmr
|
|
81
|
+
},
|
|
82
|
+
options.svelteLoaderOptions ?? {}
|
|
83
|
+
);
|
|
84
|
+
chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/).use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
pluginSvelte
|
|
92
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { CompileOptions } from 'svelte/compiler';
|
|
5
|
-
|
|
6
|
-
interface SvelteLoaderOptions {
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
3
|
+
import type { AutoPreprocessOptions, Transformer } from 'svelte-preprocess/dist/types';
|
|
4
|
+
import type { CompileOptions } from 'svelte/compiler';
|
|
5
|
+
export type { AutoPreprocessOptions, Transformer };
|
|
6
|
+
export interface SvelteLoaderOptions {
|
|
7
7
|
compilerOptions?: Omit<CompileOptions, 'filename' | 'format' | 'generate'>;
|
|
8
8
|
/**
|
|
9
9
|
* Extra HMR options, the defaults are completely fine\
|
|
@@ -16,7 +16,7 @@ interface SvelteLoaderOptions {
|
|
|
16
16
|
};
|
|
17
17
|
[key: string]: any;
|
|
18
18
|
}
|
|
19
|
-
type PluginSvelteOptions = {
|
|
19
|
+
export type PluginSvelteOptions = {
|
|
20
20
|
/**
|
|
21
21
|
* The options of svelte-loader
|
|
22
22
|
* @see https://github.com/sveltejs/svelte-loader
|
|
@@ -28,6 +28,4 @@ type PluginSvelteOptions = {
|
|
|
28
28
|
*/
|
|
29
29
|
preprocessOptions?: AutoPreprocessOptions;
|
|
30
30
|
};
|
|
31
|
-
declare function pluginSvelte(options?: PluginSvelteOptions): RsbuildPlugin;
|
|
32
|
-
|
|
33
|
-
export { type PluginSvelteOptions, type SvelteLoaderOptions, pluginSvelte };
|
|
31
|
+
export declare function pluginSvelte(options?: PluginSvelteOptions): RsbuildPlugin;
|
package/dist/index.js
CHANGED
|
@@ -1,54 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
var require = createRequire(import.meta['url']);
|
|
29
3
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
4
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
+
}) : x)(function(x) {
|
|
7
|
+
if (typeof require !== "undefined")
|
|
8
|
+
return require.apply(this, arguments);
|
|
9
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
34
10
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
11
|
+
|
|
12
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
|
|
13
|
+
import { fileURLToPath } from "url";
|
|
14
|
+
import path from "path";
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
import path2 from "path";
|
|
18
|
+
import { logger } from "@rsbuild/core";
|
|
19
|
+
import { deepmerge } from "@rsbuild/shared";
|
|
39
20
|
function pluginSvelte(options = {}) {
|
|
40
21
|
return {
|
|
41
22
|
name: "rsbuild:svelte",
|
|
42
23
|
setup(api) {
|
|
43
24
|
let sveltePath = "";
|
|
44
25
|
try {
|
|
45
|
-
sveltePath =
|
|
46
|
-
|
|
26
|
+
sveltePath = path2.dirname(
|
|
27
|
+
__require.resolve("svelte/package.json", {
|
|
47
28
|
paths: [api.context.rootPath]
|
|
48
29
|
})
|
|
49
30
|
);
|
|
50
31
|
} catch (err) {
|
|
51
|
-
|
|
32
|
+
logger.error(
|
|
52
33
|
"Cannot resolve `svelte` package under the project directory, did you forget to install it?"
|
|
53
34
|
);
|
|
54
35
|
throw new Error("Cannot resolve `svelte` package", {
|
|
@@ -58,11 +39,11 @@ function pluginSvelte(options = {}) {
|
|
|
58
39
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev }) => {
|
|
59
40
|
const { default: sveltePreprocess } = await import("svelte-preprocess");
|
|
60
41
|
const rsbuildConfig = api.getNormalizedConfig();
|
|
61
|
-
chain.resolve.alias.set("svelte",
|
|
42
|
+
chain.resolve.alias.set("svelte", path2.join(sveltePath, "src/runtime"));
|
|
62
43
|
chain.resolve.extensions.add(".svelte");
|
|
63
44
|
chain.resolve.mainFields.add("svelte").add("...");
|
|
64
45
|
chain.resolve.set("conditionNames", ["svelte", "..."]);
|
|
65
|
-
const loaderPath =
|
|
46
|
+
const loaderPath = __require.resolve("svelte-loader");
|
|
66
47
|
chain.merge({
|
|
67
48
|
resolveLoader: {
|
|
68
49
|
alias: {
|
|
@@ -70,7 +51,7 @@ function pluginSvelte(options = {}) {
|
|
|
70
51
|
}
|
|
71
52
|
}
|
|
72
53
|
});
|
|
73
|
-
const svelteLoaderOptions =
|
|
54
|
+
const svelteLoaderOptions = deepmerge(
|
|
74
55
|
{
|
|
75
56
|
compilerOptions: {
|
|
76
57
|
dev: isDev
|
|
@@ -86,7 +67,6 @@ function pluginSvelte(options = {}) {
|
|
|
86
67
|
}
|
|
87
68
|
};
|
|
88
69
|
}
|
|
89
|
-
|
|
90
|
-
0 && (module.exports = {
|
|
70
|
+
export {
|
|
91
71
|
pluginSvelte
|
|
92
|
-
}
|
|
72
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-beta.0",
|
|
4
4
|
"description": "Svelte plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
"directory": "packages/plugin-svelte"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"type": "
|
|
11
|
+
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
|
-
"import": "./dist/index.
|
|
16
|
-
"
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
-
"main": "./dist/index.
|
|
19
|
+
"main": "./dist/index.cjs",
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
21
21
|
"files": [
|
|
22
22
|
"dist"
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"svelte-loader": "3.2.0",
|
|
26
26
|
"svelte-preprocess": "^5.1.4",
|
|
27
|
-
"@rsbuild/shared": "0.
|
|
27
|
+
"@rsbuild/shared": "0.7.0-beta.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "18.x",
|
|
31
|
-
"svelte": "^4.2.
|
|
31
|
+
"svelte": "^4.2.16",
|
|
32
32
|
"typescript": "^5.4.2",
|
|
33
|
-
"@rsbuild/core": "0.
|
|
34
|
-
"@scripts/test-helper": "0.
|
|
33
|
+
"@rsbuild/core": "0.7.0-beta.0",
|
|
34
|
+
"@scripts/test-helper": "0.7.0-beta.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@rsbuild/core": "^0.
|
|
37
|
+
"@rsbuild/core": "^0.7.0-beta.0"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public",
|
package/dist/index.mjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module';
|
|
2
|
-
var require = createRequire(import.meta['url']);
|
|
3
|
-
|
|
4
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
|
-
}) : x)(function(x) {
|
|
7
|
-
if (typeof require !== "undefined")
|
|
8
|
-
return require.apply(this, arguments);
|
|
9
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.49.2_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
|
|
13
|
-
import { fileURLToPath } from "url";
|
|
14
|
-
import path from "path";
|
|
15
|
-
|
|
16
|
-
// src/index.ts
|
|
17
|
-
import path2 from "path";
|
|
18
|
-
import { logger } from "@rsbuild/core";
|
|
19
|
-
import { deepmerge } from "@rsbuild/shared";
|
|
20
|
-
function pluginSvelte(options = {}) {
|
|
21
|
-
return {
|
|
22
|
-
name: "rsbuild:svelte",
|
|
23
|
-
setup(api) {
|
|
24
|
-
let sveltePath = "";
|
|
25
|
-
try {
|
|
26
|
-
sveltePath = path2.dirname(
|
|
27
|
-
__require.resolve("svelte/package.json", {
|
|
28
|
-
paths: [api.context.rootPath]
|
|
29
|
-
})
|
|
30
|
-
);
|
|
31
|
-
} catch (err) {
|
|
32
|
-
logger.error(
|
|
33
|
-
"Cannot resolve `svelte` package under the project directory, did you forget to install it?"
|
|
34
|
-
);
|
|
35
|
-
throw new Error("Cannot resolve `svelte` package", {
|
|
36
|
-
cause: err
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev }) => {
|
|
40
|
-
const { default: sveltePreprocess } = await import("svelte-preprocess");
|
|
41
|
-
const rsbuildConfig = api.getNormalizedConfig();
|
|
42
|
-
chain.resolve.alias.set("svelte", path2.join(sveltePath, "src/runtime"));
|
|
43
|
-
chain.resolve.extensions.add(".svelte");
|
|
44
|
-
chain.resolve.mainFields.add("svelte").add("...");
|
|
45
|
-
chain.resolve.set("conditionNames", ["svelte", "..."]);
|
|
46
|
-
const loaderPath = __require.resolve("svelte-loader");
|
|
47
|
-
chain.merge({
|
|
48
|
-
resolveLoader: {
|
|
49
|
-
alias: {
|
|
50
|
-
"svelte-loader": loaderPath
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
const svelteLoaderOptions = deepmerge(
|
|
55
|
-
{
|
|
56
|
-
compilerOptions: {
|
|
57
|
-
dev: isDev
|
|
58
|
-
},
|
|
59
|
-
preprocess: sveltePreprocess(options.preprocessOptions),
|
|
60
|
-
emitCss: !rsbuildConfig.output.injectStyles,
|
|
61
|
-
hotReload: isDev && rsbuildConfig.dev.hmr
|
|
62
|
-
},
|
|
63
|
-
options.svelteLoaderOptions ?? {}
|
|
64
|
-
);
|
|
65
|
-
chain.module.rule(CHAIN_ID.RULE.SVELTE).test(/\.svelte$/).use(CHAIN_ID.USE.SVELTE).loader(loaderPath).options(svelteLoaderOptions);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
export {
|
|
71
|
-
pluginSvelte
|
|
72
|
-
};
|