@nifrajs/web-svelte 3.1.0 → 3.3.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/mdx.js +5 -5
- package/dist/mdx.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +5 -5
- package/dist/plugin.js.map +1 -1
- package/dist/svg.d.ts +10 -0
- package/dist/svg.d.ts.map +1 -1
- package/dist/svg.js +2 -1
- package/dist/svg.js.map +1 -1
- package/package.json +5 -5
- package/src/mdx.ts +5 -5
- package/src/plugin.ts +11 -5
- package/src/svg.ts +3 -1
package/dist/mdx.js
CHANGED
|
@@ -6,7 +6,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
6
6
|
}
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
|
-
import { rewriteSsrImports } from "@nifrajs/web/plugins/kit";
|
|
9
|
+
import { normalizeFilePath, portablePath, rewriteSsrImports } from "@nifrajs/web/plugins/kit";
|
|
10
10
|
import { compile } from "svelte/compiler";
|
|
11
11
|
/**
|
|
12
12
|
* `@nifrajs/web-svelte/mdx` - compile `.mdx` routes/files to **Svelte** components. Svelte has no JSX
|
|
@@ -37,7 +37,7 @@ export function svelteMdxBunPlugin(generate) {
|
|
|
37
37
|
throw new Error("@nifrajs/web-svelte/mdx: compiling `.mdx` for Svelte needs the `mdsvex` package - install it (`bun add mdsvex`).");
|
|
38
38
|
}
|
|
39
39
|
build.onLoad({ filter: /\.mdx(\?|$)/ }, async (args) => {
|
|
40
|
-
const path = args.path
|
|
40
|
+
const path = normalizeFilePath(args.path);
|
|
41
41
|
// 1. Markdown/MDX → Svelte source (mdsvex). `extensions` must include `.mdx` or mdsvex skips the
|
|
42
42
|
// file (returns undefined - it only processes its configured extensions, default `.svx`).
|
|
43
43
|
const pre = await mdsvexCompile(await Bun.file(path).text(), {
|
|
@@ -53,9 +53,9 @@ export function svelteMdxBunPlugin(generate) {
|
|
|
53
53
|
css: "external",
|
|
54
54
|
});
|
|
55
55
|
if (generate === "dom" && css?.code) {
|
|
56
|
-
cssByPath.set(path, css.code);
|
|
56
|
+
cssByPath.set(portablePath(path), css.code);
|
|
57
57
|
return {
|
|
58
|
-
contents: `${js.code}\nimport ${JSON.stringify(path + STYLE_SUFFIX)}\n`,
|
|
58
|
+
contents: `${js.code}\nimport ${JSON.stringify(portablePath(path) + STYLE_SUFFIX)}\n`,
|
|
59
59
|
loader: "js",
|
|
60
60
|
};
|
|
61
61
|
}
|
|
@@ -66,7 +66,7 @@ export function svelteMdxBunPlugin(generate) {
|
|
|
66
66
|
namespace: STYLE_NS,
|
|
67
67
|
}));
|
|
68
68
|
build.onLoad({ filter: /.*/, namespace: STYLE_NS }, (args) => ({
|
|
69
|
-
contents: cssByPath.get(args.path.slice(0, -STYLE_SUFFIX.length)) ?? "",
|
|
69
|
+
contents: cssByPath.get(portablePath(args.path.slice(0, -STYLE_SUFFIX.length))) ?? "",
|
|
70
70
|
loader: "css",
|
|
71
71
|
}));
|
|
72
72
|
},
|
package/dist/mdx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdx.js","sourceRoot":"","sources":["../src/mdx.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"mdx.js","sourceRoot":"","sources":["../src/mdx.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE7F,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC;;;;;;;;;;GAUG;AACH,MAAM,aAAa,GAAG,QAAQ,CAAA,CAAC,kEAAkE;AACjG,MAAM,YAAY,GAAG,iBAAiB,CAAA;AACtC,MAAM,QAAQ,GAAG,sBAAsB,CAAA;AAMvC;uFACuF;AACvF,M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GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;oBAC3C,OAAO;wBACL,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,YAAY,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI;wBACrF,MAAM,EAAE,IAAI;qBACb,CAAA;gBACH,CAAC;gBACD,OAAO,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;YAC/E,CAAC,CAAC,CAAA;YACF,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC1D,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,SAAS,EAAE,QAAQ;aACpB,CAAC,CAAC,CAAA;YACH,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC7D,QAAQ,EAAE,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE;gBACrF,MAAM,EAAE,KAAK;aACd,CAAC,CAAC,CAAA;QACL,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAsBpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,CAEtF;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,CA8DlE"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { devHotComponent, devServerCompile, rewriteSsrImports } from "@nifrajs/web/plugins/kit";
|
|
1
|
+
import { devHotComponent, devServerCompile, normalizeFilePath, portablePath, rewriteSsrImports, } from "@nifrajs/web/plugins/kit";
|
|
2
2
|
import { compile } from "svelte/compiler";
|
|
3
3
|
/**
|
|
4
4
|
* `@nifrajs/web-svelte/plugin` - the `.svelte` compiler Bun-plugin, in its OWN module (no `.svelte`
|
|
@@ -49,7 +49,7 @@ export function svelteBunPlugin(generate) {
|
|
|
49
49
|
// Match `.svelte`, tolerating a `?query` suffix (dev servers append one to bust Bun's import
|
|
50
50
|
// cache); strip it before reading the file off disk.
|
|
51
51
|
build.onLoad({ filter: /\.svelte(\?|$)/ }, async (args) => {
|
|
52
|
-
const path = args.path
|
|
52
|
+
const path = normalizeFilePath(args.path);
|
|
53
53
|
const source = await Bun.file(path).text();
|
|
54
54
|
// Per compile, not per registration: the CLI registers the SSR plugin before the dev server
|
|
55
55
|
// exists, and the flag is set by the dev server.
|
|
@@ -82,10 +82,10 @@ export function svelteBunPlugin(generate) {
|
|
|
82
82
|
hmr: dev && generate === "dom" && devHotComponent(path),
|
|
83
83
|
});
|
|
84
84
|
if (generate === "dom" && css?.code) {
|
|
85
|
-
cssByPath.set(path, css.code);
|
|
85
|
+
cssByPath.set(portablePath(path), css.code);
|
|
86
86
|
// Import the virtual style module so the bundler pulls the scoped CSS into the app stylesheet.
|
|
87
87
|
return {
|
|
88
|
-
contents: `${js.code}\nimport ${JSON.stringify(path + STYLE_SUFFIX)}\n`,
|
|
88
|
+
contents: `${js.code}\nimport ${JSON.stringify(portablePath(path) + STYLE_SUFFIX)}\n`,
|
|
89
89
|
loader: "js",
|
|
90
90
|
};
|
|
91
91
|
}
|
|
@@ -97,7 +97,7 @@ export function svelteBunPlugin(generate) {
|
|
|
97
97
|
namespace: STYLE_NS,
|
|
98
98
|
}));
|
|
99
99
|
build.onLoad({ filter: /.*/, namespace: STYLE_NS }, (args) => ({
|
|
100
|
-
contents: cssByPath.get(args.path.slice(0, -STYLE_SUFFIX.length)) ?? "",
|
|
100
|
+
contents: cssByPath.get(portablePath(args.path.slice(0, -STYLE_SUFFIX.length))) ?? "",
|
|
101
101
|
loader: "css",
|
|
102
102
|
}));
|
|
103
103
|
},
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,GAClB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,YAAY,GAAG,aAAa,CAAA;AAClC,MAAM,QAAQ,GAAG,kBAAkB,CAAA;AAEnC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAE,QAAQ,EAAwB;IAClE,OAAO,EAAE,GAAG,EAAE,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAA;AAC3C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAAuB;IACrD,uGAAuG;IACvG,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC3C,OAAO;QACL,IAA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AAA;oBAC3C,+FAA+F;oBAC/F,OAAO;wBACL,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,YAAY,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI;wBACrF,MAAM,EAAE,IAAI;qBACb,CAAA;gBACH,CAAC;gBACD,OAAO,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;YAC/E,CAAC,CAAC,CAAA;YACF,gGAAgG;YAChG,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACtD,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,SAAS,EAAE,QAAQ;aACpB,CAAC,CAAC,CAAA;YACH,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC7D,QAAQ,EAAE,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE;gBACrF,MAAM,EAAE,KAAK;aACd,CAAC,CAAC,CAAA;QACL,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/svg.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nifrajs/web-svelte/svg` - the Svelte build of the SVG-as-component plugin. `import Icon from
|
|
3
|
+
* "./icon.svg?component"`, then `<Icon class="w-6 h-6" />`, props spread onto the root `<svg>`.
|
|
4
|
+
*
|
|
5
|
+
* Svelte markup accepts SVG almost verbatim (`class`, hyphenated attributes, an inline `style` string
|
|
6
|
+
* all work as-is), so - unlike the JSX adapters - no attribute rewriting is needed: the raw SVG is
|
|
7
|
+
* wrapped in a Svelte 5 component that spreads its props onto the root element, then compiled with the
|
|
8
|
+
* project's `svelte` compiler. Pass `"dom"` for the client bundle and preload `"ssr"` for the server;
|
|
9
|
+
* a plain `import "./icon.svg"` (asset URL) is untouched - only `?component` matches.
|
|
10
|
+
*/
|
|
1
11
|
import type { BunPlugin } from "bun";
|
|
2
12
|
/** Wrap raw SVG XML in a Svelte 5 component: strip XML noise, spread props onto the root `<svg>`. */
|
|
3
13
|
export declare function svgToSvelte(xml: string): string;
|
package/dist/svg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAGpC,qGAAqG;AACrG,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;wBACwB;AACxB,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,CAe9E"}
|
package/dist/svg.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* project's `svelte` compiler. Pass `"dom"` for the client bundle and preload `"ssr"` for the server;
|
|
9
9
|
* a plain `import "./icon.svg"` (asset URL) is untouched - only `?component` matches.
|
|
10
10
|
*/
|
|
11
|
+
import { normalizeFilePath } from "@nifrajs/web/plugins/kit";
|
|
11
12
|
import { SVG_COMPONENT_FILTER, stripSvgPreamble } from "@nifrajs/web/plugins/svg";
|
|
12
13
|
import { compile } from "svelte/compiler";
|
|
13
14
|
/** Wrap raw SVG XML in a Svelte 5 component: strip XML noise, spread props onto the root `<svg>`. */
|
|
@@ -24,7 +25,7 @@ export function svelteSvgComponentBunPlugin(generate) {
|
|
|
24
25
|
name: `nifra-svelte-svg-${generate}`,
|
|
25
26
|
setup(build) {
|
|
26
27
|
build.onLoad({ filter: SVG_COMPONENT_FILTER }, async (args) => {
|
|
27
|
-
const path = args.path
|
|
28
|
+
const path = normalizeFilePath(args.path);
|
|
28
29
|
const xml = await Bun.file(path).text();
|
|
29
30
|
const { js } = compile(svgToSvelte(xml), {
|
|
30
31
|
generate: generate === "ssr" ? "server" : "client",
|
package/dist/svg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAEjF,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC,qGAAqG;AACrG,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAA;IACrC,+FAA+F;IAC/F,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACxE,OAAO,4CAA4C,UAAU,IAAI,CAAA;AACnE,CAAC;AAED;wBACwB;AACxB,MAAM,UAAU,2BAA2B,CAAC,QAAuB;IACjE,OAAO;QACL,IAAI,EAAE,oBAAoB,QAAQ,EAAE;QACpC,KAAK,CAAC,KAAK;YACT,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,oBAAoB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBAC5D,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACzC,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;gBACvC,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;oBACvC,QAAQ,EAAE,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;oBAClD,QAAQ,EAAE,IAAI;iBACf,CAAC,CAAA;gBACF,OAAO,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;YAC5C,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nifrajs/web-svelte",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Svelte 5 render adapter for @nifrajs/web - SSR + hydration + the .svelte compiler Bun-plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -100,10 +100,10 @@
|
|
|
100
100
|
"access": "public"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@nifrajs/core": "3.
|
|
104
|
-
"@nifrajs/i18n": "3.
|
|
105
|
-
"@nifrajs/image": "3.
|
|
106
|
-
"@nifrajs/web": "3.
|
|
103
|
+
"@nifrajs/core": "3.3.0",
|
|
104
|
+
"@nifrajs/i18n": "3.3.0",
|
|
105
|
+
"@nifrajs/image": "3.3.0",
|
|
106
|
+
"@nifrajs/web": "3.3.0"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
109
|
"mdsvex": "^0.12",
|
package/src/mdx.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rewriteSsrImports } from "@nifrajs/web/plugins/kit"
|
|
1
|
+
import { normalizeFilePath, portablePath, rewriteSsrImports } from "@nifrajs/web/plugins/kit"
|
|
2
2
|
import type { BunPlugin } from "bun"
|
|
3
3
|
import { compile } from "svelte/compiler"
|
|
4
4
|
|
|
@@ -37,7 +37,7 @@ export function svelteMdxBunPlugin(generate: "dom" | "ssr"): BunPlugin {
|
|
|
37
37
|
)
|
|
38
38
|
}
|
|
39
39
|
build.onLoad({ filter: /\.mdx(\?|$)/ }, async (args) => {
|
|
40
|
-
const path = args.path
|
|
40
|
+
const path = normalizeFilePath(args.path)
|
|
41
41
|
// 1. Markdown/MDX → Svelte source (mdsvex). `extensions` must include `.mdx` or mdsvex skips the
|
|
42
42
|
// file (returns undefined - it only processes its configured extensions, default `.svx`).
|
|
43
43
|
const pre = await mdsvexCompile(await Bun.file(path).text(), {
|
|
@@ -52,9 +52,9 @@ export function svelteMdxBunPlugin(generate: "dom" | "ssr"): BunPlugin {
|
|
|
52
52
|
css: "external",
|
|
53
53
|
})
|
|
54
54
|
if (generate === "dom" && css?.code) {
|
|
55
|
-
cssByPath.set(path, css.code)
|
|
55
|
+
cssByPath.set(portablePath(path), css.code)
|
|
56
56
|
return {
|
|
57
|
-
contents: `${js.code}\nimport ${JSON.stringify(path + STYLE_SUFFIX)}\n`,
|
|
57
|
+
contents: `${js.code}\nimport ${JSON.stringify(portablePath(path) + STYLE_SUFFIX)}\n`,
|
|
58
58
|
loader: "js",
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -65,7 +65,7 @@ export function svelteMdxBunPlugin(generate: "dom" | "ssr"): BunPlugin {
|
|
|
65
65
|
namespace: STYLE_NS,
|
|
66
66
|
}))
|
|
67
67
|
build.onLoad({ filter: /.*/, namespace: STYLE_NS }, (args) => ({
|
|
68
|
-
contents: cssByPath.get(args.path.slice(0, -STYLE_SUFFIX.length)) ?? "",
|
|
68
|
+
contents: cssByPath.get(portablePath(args.path.slice(0, -STYLE_SUFFIX.length))) ?? "",
|
|
69
69
|
loader: "css",
|
|
70
70
|
}))
|
|
71
71
|
},
|
package/src/plugin.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
devHotComponent,
|
|
3
|
+
devServerCompile,
|
|
4
|
+
normalizeFilePath,
|
|
5
|
+
portablePath,
|
|
6
|
+
rewriteSsrImports,
|
|
7
|
+
} from "@nifrajs/web/plugins/kit"
|
|
2
8
|
import type { BunPlugin } from "bun"
|
|
3
9
|
import { compile } from "svelte/compiler"
|
|
4
10
|
|
|
@@ -53,7 +59,7 @@ export function svelteBunPlugin(generate: "dom" | "ssr"): BunPlugin {
|
|
|
53
59
|
// Match `.svelte`, tolerating a `?query` suffix (dev servers append one to bust Bun's import
|
|
54
60
|
// cache); strip it before reading the file off disk.
|
|
55
61
|
build.onLoad({ filter: /\.svelte(\?|$)/ }, async (args) => {
|
|
56
|
-
const path = args.path
|
|
62
|
+
const path = normalizeFilePath(args.path)
|
|
57
63
|
const source = await Bun.file(path).text()
|
|
58
64
|
// Per compile, not per registration: the CLI registers the SSR plugin before the dev server
|
|
59
65
|
// exists, and the flag is set by the dev server.
|
|
@@ -86,10 +92,10 @@ export function svelteBunPlugin(generate: "dom" | "ssr"): BunPlugin {
|
|
|
86
92
|
hmr: dev && generate === "dom" && devHotComponent(path),
|
|
87
93
|
})
|
|
88
94
|
if (generate === "dom" && css?.code) {
|
|
89
|
-
cssByPath.set(path, css.code)
|
|
95
|
+
cssByPath.set(portablePath(path), css.code)
|
|
90
96
|
// Import the virtual style module so the bundler pulls the scoped CSS into the app stylesheet.
|
|
91
97
|
return {
|
|
92
|
-
contents: `${js.code}\nimport ${JSON.stringify(path + STYLE_SUFFIX)}\n`,
|
|
98
|
+
contents: `${js.code}\nimport ${JSON.stringify(portablePath(path) + STYLE_SUFFIX)}\n`,
|
|
93
99
|
loader: "js",
|
|
94
100
|
}
|
|
95
101
|
}
|
|
@@ -101,7 +107,7 @@ export function svelteBunPlugin(generate: "dom" | "ssr"): BunPlugin {
|
|
|
101
107
|
namespace: STYLE_NS,
|
|
102
108
|
}))
|
|
103
109
|
build.onLoad({ filter: /.*/, namespace: STYLE_NS }, (args) => ({
|
|
104
|
-
contents: cssByPath.get(args.path.slice(0, -STYLE_SUFFIX.length)) ?? "",
|
|
110
|
+
contents: cssByPath.get(portablePath(args.path.slice(0, -STYLE_SUFFIX.length))) ?? "",
|
|
105
111
|
loader: "css",
|
|
106
112
|
}))
|
|
107
113
|
},
|
package/src/svg.ts
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* project's `svelte` compiler. Pass `"dom"` for the client bundle and preload `"ssr"` for the server;
|
|
9
9
|
* a plain `import "./icon.svg"` (asset URL) is untouched - only `?component` matches.
|
|
10
10
|
*/
|
|
11
|
+
|
|
12
|
+
import { normalizeFilePath } from "@nifrajs/web/plugins/kit"
|
|
11
13
|
import { SVG_COMPONENT_FILTER, stripSvgPreamble } from "@nifrajs/web/plugins/svg"
|
|
12
14
|
import type { BunPlugin } from "bun"
|
|
13
15
|
import { compile } from "svelte/compiler"
|
|
@@ -27,7 +29,7 @@ export function svelteSvgComponentBunPlugin(generate: "dom" | "ssr"): BunPlugin
|
|
|
27
29
|
name: `nifra-svelte-svg-${generate}`,
|
|
28
30
|
setup(build) {
|
|
29
31
|
build.onLoad({ filter: SVG_COMPONENT_FILTER }, async (args) => {
|
|
30
|
-
const path = args.path
|
|
32
|
+
const path = normalizeFilePath(args.path)
|
|
31
33
|
const xml = await Bun.file(path).text()
|
|
32
34
|
const { js } = compile(svgToSvelte(xml), {
|
|
33
35
|
generate: generate === "ssr" ? "server" : "client",
|