@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/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
1
|
+
import { UserConfig, Plugin } from 'vite';
|
|
2
2
|
import { CompileOptions, Warning } from 'svelte/types/compiler/interfaces';
|
|
3
3
|
export { CompileOptions, Warning } from 'svelte/types/compiler/interfaces';
|
|
4
4
|
import { PreprocessorGroup } from 'svelte/types/compiler/preprocess';
|
|
@@ -200,6 +200,8 @@ declare type ModuleFormat = NonNullable<CompileOptions['format']>;
|
|
|
200
200
|
declare type CssHashGetter = NonNullable<CompileOptions['cssHash']>;
|
|
201
201
|
declare type Arrayable<T> = T | T[];
|
|
202
202
|
|
|
203
|
+
declare function loadSvelteConfig(viteConfig?: UserConfig, inlineOptions?: Partial<Options>): Promise<Partial<Options> | undefined>;
|
|
204
|
+
|
|
203
205
|
declare function svelte(inlineOptions?: Partial<Options>): Plugin[];
|
|
204
206
|
|
|
205
|
-
export { Arrayable, CssHashGetter, ModuleFormat, Options, svelte };
|
|
207
|
+
export { Arrayable, CssHashGetter, ModuleFormat, Options, loadSvelteConfig, svelte };
|
package/dist/index.js
CHANGED
|
@@ -457,9 +457,9 @@ var knownSvelteConfigNames = [
|
|
|
457
457
|
"svelte.config.cjs",
|
|
458
458
|
"svelte.config.mjs"
|
|
459
459
|
];
|
|
460
|
-
var dynamicImportDefault = new Function("path", 'return import(path + "?t=" +
|
|
460
|
+
var dynamicImportDefault = new Function("path", "timestamp", 'return import(path + "?t=" + timestamp).then(m => m.default)');
|
|
461
461
|
async function loadSvelteConfig(viteConfig, inlineOptions) {
|
|
462
|
-
if (inlineOptions.configFile === false) {
|
|
462
|
+
if ((inlineOptions == null ? void 0 : inlineOptions.configFile) === false) {
|
|
463
463
|
return;
|
|
464
464
|
}
|
|
465
465
|
const configFile = findConfigToLoad(viteConfig, inlineOptions);
|
|
@@ -467,7 +467,7 @@ async function loadSvelteConfig(viteConfig, inlineOptions) {
|
|
|
467
467
|
let err;
|
|
468
468
|
if (configFile.endsWith(".js") || configFile.endsWith(".mjs")) {
|
|
469
469
|
try {
|
|
470
|
-
const result = await dynamicImportDefault(pathToFileURL(configFile).href);
|
|
470
|
+
const result = await dynamicImportDefault(pathToFileURL(configFile).href, fs2.statSync(configFile).mtimeMs);
|
|
471
471
|
if (result != null) {
|
|
472
472
|
return __spreadProps(__spreadValues({}, result), {
|
|
473
473
|
configFile
|
|
@@ -503,8 +503,8 @@ async function loadSvelteConfig(viteConfig, inlineOptions) {
|
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
function findConfigToLoad(viteConfig, inlineOptions) {
|
|
506
|
-
const root = viteConfig.root || process.cwd();
|
|
507
|
-
if (inlineOptions.configFile) {
|
|
506
|
+
const root = (viteConfig == null ? void 0 : viteConfig.root) || process.cwd();
|
|
507
|
+
if (inlineOptions == null ? void 0 : inlineOptions.configFile) {
|
|
508
508
|
const abolutePath = path.isAbsolute(inlineOptions.configFile) ? inlineOptions.configFile : path.resolve(root, inlineOptions.configFile);
|
|
509
509
|
if (!fs2.existsSync(abolutePath)) {
|
|
510
510
|
throw new Error(`failed to find svelte config file ${abolutePath}.`);
|
|
@@ -1759,6 +1759,7 @@ function svelte(inlineOptions) {
|
|
|
1759
1759
|
return plugins.filter(Boolean);
|
|
1760
1760
|
}
|
|
1761
1761
|
export {
|
|
1762
|
+
loadSvelteConfig,
|
|
1762
1763
|
svelte
|
|
1763
1764
|
};
|
|
1764
1765
|
//# sourceMappingURL=index.js.map
|