@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/vite-plugin-svelte",
3
- "version": "1.0.0-next.46",
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.39",
66
- "rollup": "^2.74.1",
65
+ "esbuild": "^0.14.42",
66
+ "rollup": "^2.75.4",
67
67
  "svelte": "^3.48.0",
68
- "tsup": "^5.12.8",
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 --target node14",
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
@@ -218,6 +218,8 @@ export function svelte(inlineOptions?: Partial<Options>): Plugin[] {
218
218
  return plugins.filter(Boolean);
219
219
  }
220
220
 
221
+ export { loadSvelteConfig } from './utils/load-svelte-config';
222
+
221
223
  export {
222
224
  Options,
223
225
  Preprocessor,
@@ -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
- 'return import(path + "?t=" + Date.now()).then(m => m.default)'
25
+ 'timestamp',
26
+ 'return import(path + "?t=" + timestamp).then(m => m.default)'
26
27
  );
27
28
 
28
29
  export async function loadSvelteConfig(
29
- viteConfig: UserConfig,
30
- inlineOptions: Partial<Options>
30
+ viteConfig?: UserConfig,
31
+ inlineOptions?: Partial<Options>
31
32
  ): Promise<Partial<Options> | undefined> {
32
- if (inlineOptions.configFile === false) {
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(pathToFileURL(configFile).href);
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: UserConfig, inlineOptions: Partial<Options>) {
87
- const root = viteConfig.root || process.cwd();
88
- if (inlineOptions.configFile) {
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);