@sveltejs/vite-plugin-svelte 1.0.0-next.46 → 1.0.0-next.47
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 +8 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +2 -0
- package/src/utils/load-svelte-config.ts +12 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/vite-plugin-svelte",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.47",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "dominikg",
|
|
6
6
|
"files": [
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
"@types/debug": "^4.1.7",
|
|
63
63
|
"@types/diff-match-patch": "^1.0.32",
|
|
64
64
|
"diff-match-patch": "^1.0.5",
|
|
65
|
-
"esbuild": "^0.14.
|
|
66
|
-
"rollup": "^2.
|
|
65
|
+
"esbuild": "^0.14.42",
|
|
66
|
+
"rollup": "^2.75.4",
|
|
67
67
|
"svelte": "^3.48.0",
|
|
68
|
-
"tsup": "^
|
|
68
|
+
"tsup": "^6.0.1",
|
|
69
69
|
"vite": "^2.9.9"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"dev": "pnpm build:ci --sourcemap --watch src",
|
|
73
|
-
"build:ci": "rimraf dist && tsup-node src/index.ts --format esm,cjs --no-splitting --
|
|
73
|
+
"build:ci": "rimraf dist && tsup-node src/index.ts --format esm,cjs --no-splitting --shims",
|
|
74
74
|
"build": "pnpm build:ci --dts --sourcemap"
|
|
75
75
|
}
|
|
76
76
|
}
|
package/src/index.ts
CHANGED
|
@@ -22,14 +22,15 @@ export const knownSvelteConfigNames = [
|
|
|
22
22
|
// also use timestamp query to avoid caching on reload
|
|
23
23
|
const dynamicImportDefault = new Function(
|
|
24
24
|
'path',
|
|
25
|
-
'
|
|
25
|
+
'timestamp',
|
|
26
|
+
'return import(path + "?t=" + timestamp).then(m => m.default)'
|
|
26
27
|
);
|
|
27
28
|
|
|
28
29
|
export async function loadSvelteConfig(
|
|
29
|
-
viteConfig
|
|
30
|
-
inlineOptions
|
|
30
|
+
viteConfig?: UserConfig,
|
|
31
|
+
inlineOptions?: Partial<Options>
|
|
31
32
|
): Promise<Partial<Options> | undefined> {
|
|
32
|
-
if (inlineOptions
|
|
33
|
+
if (inlineOptions?.configFile === false) {
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
36
|
const configFile = findConfigToLoad(viteConfig, inlineOptions);
|
|
@@ -38,7 +39,10 @@ export async function loadSvelteConfig(
|
|
|
38
39
|
// try to use dynamic import for svelte.config.js first
|
|
39
40
|
if (configFile.endsWith('.js') || configFile.endsWith('.mjs')) {
|
|
40
41
|
try {
|
|
41
|
-
const result = await dynamicImportDefault(
|
|
42
|
+
const result = await dynamicImportDefault(
|
|
43
|
+
pathToFileURL(configFile).href,
|
|
44
|
+
fs.statSync(configFile).mtimeMs
|
|
45
|
+
);
|
|
42
46
|
if (result != null) {
|
|
43
47
|
return {
|
|
44
48
|
...result,
|
|
@@ -83,9 +87,9 @@ export async function loadSvelteConfig(
|
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
|
|
86
|
-
function findConfigToLoad(viteConfig
|
|
87
|
-
const root = viteConfig
|
|
88
|
-
if (inlineOptions
|
|
90
|
+
function findConfigToLoad(viteConfig?: UserConfig, inlineOptions?: Partial<Options>) {
|
|
91
|
+
const root = viteConfig?.root || process.cwd();
|
|
92
|
+
if (inlineOptions?.configFile) {
|
|
89
93
|
const abolutePath = path.isAbsolute(inlineOptions.configFile)
|
|
90
94
|
? inlineOptions.configFile
|
|
91
95
|
: path.resolve(root, inlineOptions.configFile);
|