@vigla/vite-plugin-svelte 0.0.0-stage → 7.3.1
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/history.d.ts +3 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +26 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/messages.d.ts +3 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +16 -0
- package/dist/messages.js.map +1 -0
- package/dist/names.d.ts +3 -0
- package/dist/names.d.ts.map +1 -0
- package/dist/names.js +24 -0
- package/dist/names.js.map +1 -0
- package/package.json +18 -5
- package/src/history.ts +33 -0
- package/src/index.ts +55 -0
- package/src/messages.ts +26 -0
- package/src/names.ts +26 -0
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAOlD,eAAO,MAAM,OAAO,EAAE,OAyBrB,CAAC"}
|
package/dist/history.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const transformLink = 'https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/advanced-usage.md#transform-svelte-files-with-vite-plugins';
|
|
2
|
+
const promoted = ['prebundleSvelteLibraries', 'inspector', 'dynamicCompileOptions'];
|
|
3
|
+
export const history = {
|
|
4
|
+
options(options, log) {
|
|
5
|
+
const experimental = options.experimental;
|
|
6
|
+
if (!experimental)
|
|
7
|
+
return;
|
|
8
|
+
for (const key of promoted) {
|
|
9
|
+
if (!experimental[key])
|
|
10
|
+
continue;
|
|
11
|
+
options[key] = experimental[key];
|
|
12
|
+
delete experimental[key];
|
|
13
|
+
log.warn(`Option "experimental.${key}" is no longer experimental and has moved to "${key}". Please update your Svelte or Vite config.`);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
config(config, log) {
|
|
17
|
+
const using = config.plugins.filter((plugin) => plugin?.api?.sveltePreprocess);
|
|
18
|
+
if (using.length === 0)
|
|
19
|
+
return;
|
|
20
|
+
log.error.once(`The following vite plugins use the removed 'plugin.api.sveltePreprocess' api: ${using.map((plugin) => plugin.name).join(', ')}
|
|
21
|
+
These preprocessors are no longer added to your svelte config and if your application depends on them it breaks.
|
|
22
|
+
Update the plugins or contact their maintainers. See ${transformLink} for more information.
|
|
23
|
+
`.replace(/\t+/g, '\t'));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAClB,0HAA0H,CAAC;AAE5H,MAAM,QAAQ,GAAG,CAAC,0BAA0B,EAAE,WAAW,EAAE,uBAAuB,CAAC,CAAC;AAEpF,MAAM,CAAC,MAAM,OAAO,GAAY;IAC/B,OAAO,CAAC,OAAO,EAAE,GAAG;QACnB,MAAM,YAAY,GAAG,OAAO,CAAC,YAAmD,CAAC;QACjF,IAAI,CAAC,YAAY;YAAE,OAAO;QAC1B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;YAC5B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;gBAAE,SAAS;YACjC,OAAO,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;YACjC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;YACzB,GAAG,CAAC,IAAI,CACP,wBAAwB,GAAG,iDAAiD,GAAG,8CAA8C,CAC7H,CAAC;QACH,CAAC;IACF,CAAC;IACD,MAAM,CAAC,MAAM,EAAE,GAAG;QACjB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAClC,CAAC,MAAM,EAAE,EAAE,CAAE,MAAM,EAAE,GAAkD,EAAE,gBAAgB,CACzF,CAAC;QACF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC/B,GAAG,CAAC,KAAK,CAAC,IAAI,CACb,iFAAiF,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;2DAEtE,aAAa;KACnE,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CACxB,CAAC;IACH,CAAC;CACD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Config, type ExperimentalOptions, type PluginFactory, type PluginOptions as ProductPluginOptions } from '@vigla/vite-plugin';
|
|
2
|
+
import type { UserConfig } from 'vite';
|
|
3
|
+
export { vitePreprocess } from '@vigla/vite-plugin';
|
|
4
|
+
export type { VitePreprocessOptions } from '@vigla/vite-plugin';
|
|
5
|
+
export interface ExperimentalPluginOptions extends Omit<ExperimentalOptions, 'disableResolveWarnings'> {
|
|
6
|
+
disableSvelteResolveWarnings?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface PluginOptions extends Omit<ProductPluginOptions, 'prebundleLibraries' | 'experimental'> {
|
|
9
|
+
prebundleSvelteLibraries?: boolean;
|
|
10
|
+
experimental?: ExperimentalPluginOptions;
|
|
11
|
+
}
|
|
12
|
+
export interface SvelteConfig extends Omit<Config, 'vitePlugin'> {
|
|
13
|
+
vitePlugin?: PluginOptions;
|
|
14
|
+
}
|
|
15
|
+
export interface Options extends Omit<SvelteConfig, 'vitePlugin'>, PluginOptions {
|
|
16
|
+
configFile?: string | false;
|
|
17
|
+
}
|
|
18
|
+
export type LoadedSvelteConfig = Partial<SvelteConfig> & {
|
|
19
|
+
configFile?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const svelte: PluginFactory<Options>;
|
|
22
|
+
export declare function loadSvelteConfig(viteConfig?: UserConfig, inline?: Partial<Options>): Promise<LoadedSvelteConfig | undefined>;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,MAAM,EACX,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,aAAa,IAAI,oBAAoB,EAC1C,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAKvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,MAAM,WAAW,yBAA0B,SAAQ,IAAI,CACtD,mBAAmB,EACnB,wBAAwB,CACxB;IACA,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CAC1C,oBAAoB,EACpB,oBAAoB,GAAG,cAAc,CACrC;IACA,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,YAAY,CAAC,EAAE,yBAAyB,CAAC;CACzC;AAED,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;IAC/D,UAAU,CAAC,EAAE,aAAa,CAAC;CAC3B;AAED,MAAM,WAAW,OAAQ,SAAQ,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,EAAE,aAAa;IAC/E,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC5B;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF,eAAO,MAAM,MAAM,EAAE,aAAa,CAAC,OAAO,CAKxC,CAAC;AAEH,wBAAgB,gBAAgB,CAC/B,UAAU,CAAC,EAAE,UAAU,EACvB,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GACvB,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAIzC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createPlugin } from '@vigla/vite-plugin';
|
|
2
|
+
import { history } from './history.js';
|
|
3
|
+
import { messages } from './messages.js';
|
|
4
|
+
import { names } from './names.js';
|
|
5
|
+
export { vitePreprocess } from '@vigla/vite-plugin';
|
|
6
|
+
export const svelte = createPlugin({
|
|
7
|
+
name: 'vite-plugin-svelte',
|
|
8
|
+
names,
|
|
9
|
+
messages,
|
|
10
|
+
history
|
|
11
|
+
});
|
|
12
|
+
export function loadSvelteConfig(viteConfig, inline) {
|
|
13
|
+
return svelte.loadConfig(viteConfig, inline, 'svelte.config');
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EAKZ,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AA4BpD,MAAM,CAAC,MAAM,MAAM,GAA2B,YAAY,CAAU;IACnE,IAAI,EAAE,oBAAoB;IAC1B,KAAK;IACL,QAAQ;IACR,OAAO;CACP,CAAC,CAAC;AAEH,MAAM,UAAU,gBAAgB,CAC/B,UAAuB,EACvB,MAAyB;IAEzB,OAAO,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,CAE3D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,eAAO,MAAM,QAAQ,EAAE,QAuBtB,CAAC"}
|
package/dist/messages.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const messages = {
|
|
2
|
+
configChangeDetected: 'Svelte config change detected, restart your dev process to apply the changes.',
|
|
3
|
+
configChanged: (file) => `svelte config changed: restarting vite server. - file: ${file}`,
|
|
4
|
+
noClientEnvironment: 'No client environment found, not adding watchers for svelte config and preprocessor dependencies',
|
|
5
|
+
configNotFound: (file) => `failed to find svelte config file ${file}.`,
|
|
6
|
+
configAbsent: (root) => `no Svelte config found at ${root} - using default configuration.`,
|
|
7
|
+
configsMultiple: (file) => `found more than one svelte config file, using ${file}. you should only have one!`,
|
|
8
|
+
optionsMisplaced: (keys) => `Invalid options in svelte config. Move the following options into 'vitePlugin:{...}': ${keys}`,
|
|
9
|
+
optionsAtRoot: (keys) => `Invalid options in svelte config under vitePlugin:{...}', move them to the config root : ${keys}`,
|
|
10
|
+
optionsDuplicate: (keys) => `Invalid duplicate options in svelte config under vitePlugin:{...}', they are defined in root too and must only exist once: ${keys}`,
|
|
11
|
+
optionsUnknown: (keys) => `ignoring unknown plugin options in svelte config under vitePlugin:{...}: ${keys}`,
|
|
12
|
+
cssHash: 'The custom compilerOptions.cssHash in your svelte config can degrade your DX.',
|
|
13
|
+
controlledOptions: (plugin, keys) => `The following Svelte compilerOptions are controlled by ${plugin} and essential to its functionality. User-specified values are ignored. Please remove them from your configuration: ${keys}`,
|
|
14
|
+
missingCondition: () => 'The following packages have a svelte field in their package.json but no exports condition for svelte.'
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAa;IACjC,oBAAoB,EACnB,+EAA+E;IAChF,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,0DAA0D,IAAI,EAAE;IACzF,mBAAmB,EAClB,kGAAkG;IACnG,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,qCAAqC,IAAI,GAAG;IACtE,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,6BAA6B,IAAI,iCAAiC;IAC1F,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,CACzB,iDAAiD,IAAI,6BAA6B;IACnF,gBAAgB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC1B,yFAAyF,IAAI,EAAE;IAChG,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CACvB,4FAA4F,IAAI,EAAE;IACnG,gBAAgB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC1B,8HAA8H,IAAI,EAAE;IACrI,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CACxB,4EAA4E,IAAI,EAAE;IACnF,OAAO,EAAE,+EAA+E;IACxF,iBAAiB,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CACnC,0DAA0D,MAAM,uHAAuH,IAAI,EAAE;IAC9L,gBAAgB,EAAE,GAAG,EAAE,CACtB,uGAAuG;CACxG,CAAC"}
|
package/dist/names.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../src/names.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAIhD,eAAO,MAAM,KAAK,EAAE,OAAO,CAAC,KAAK,CAqBhC,CAAC"}
|
package/dist/names.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const docs = 'https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs';
|
|
2
|
+
export const names = {
|
|
3
|
+
prebundle: 'prebundleSvelteLibraries',
|
|
4
|
+
resolveWarnings: 'disableSvelteResolveWarnings',
|
|
5
|
+
warningsEvent: 'svelte:warnings',
|
|
6
|
+
styleFlag: 'svelte',
|
|
7
|
+
metaKey: 'svelte',
|
|
8
|
+
metadataFile: '_svelte_metadata.json',
|
|
9
|
+
withoutSources: [
|
|
10
|
+
'@sveltejs/kit',
|
|
11
|
+
'@sveltejs/package',
|
|
12
|
+
'@sveltejs/vite-plugin-svelte',
|
|
13
|
+
'svelte2tsx',
|
|
14
|
+
'svelte-check',
|
|
15
|
+
'svelte-preprocess'
|
|
16
|
+
],
|
|
17
|
+
withoutSourcesPrefixes: ['@sveltejs/adapter-'],
|
|
18
|
+
links: {
|
|
19
|
+
cssHash: `${docs}/faq.md#why-should-csshash-be-calculated-from-filename-during-dev`,
|
|
20
|
+
preprocess: `${docs}/preprocess.md`,
|
|
21
|
+
missingCondition: `${docs}/faq.md#missing-exports-condition`
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../src/names.ts"],"names":[],"mappings":"AAEA,MAAM,IAAI,GAAG,+DAA+D,CAAC;AAE7E,MAAM,CAAC,MAAM,KAAK,GAAmB;IACpC,SAAS,EAAE,0BAA0B;IACrC,eAAe,EAAE,8BAA8B;IAC/C,aAAa,EAAE,iBAAiB;IAChC,SAAS,EAAE,QAAQ;IACnB,OAAO,EAAE,QAAQ;IACjB,YAAY,EAAE,uBAAuB;IACrC,cAAc,EAAE;QACf,eAAe;QACf,mBAAmB;QACnB,8BAA8B;QAC9B,YAAY;QACZ,cAAc;QACd,mBAAmB;KACnB;IACD,sBAAsB,EAAE,CAAC,oBAAoB,CAAC;IAC9C,KAAK,EAAE;QACN,OAAO,EAAE,GAAG,IAAI,mEAAmE;QACnF,UAAU,EAAE,GAAG,IAAI,gBAAgB;QACnC,gBAAgB,EAAE,GAAG,IAAI,mCAAmC;KAC5D;CACD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@vigla/vite-plugin-svelte",
|
|
3
|
+
"version": "7.3.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"src"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@vigla/vite-plugin": "0.1.0"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"svelte": "^5.46.4",
|
|
17
|
+
"vite": "^8.0.0"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/history.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { History } from '@vigla/vite-plugin';
|
|
2
|
+
|
|
3
|
+
const transformLink =
|
|
4
|
+
'https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/advanced-usage.md#transform-svelte-files-with-vite-plugins';
|
|
5
|
+
|
|
6
|
+
const promoted = ['prebundleSvelteLibraries', 'inspector', 'dynamicCompileOptions'];
|
|
7
|
+
|
|
8
|
+
export const history: History = {
|
|
9
|
+
options(options, log) {
|
|
10
|
+
const experimental = options.experimental as Record<string, unknown> | undefined;
|
|
11
|
+
if (!experimental) return;
|
|
12
|
+
for (const key of promoted) {
|
|
13
|
+
if (!experimental[key]) continue;
|
|
14
|
+
options[key] = experimental[key];
|
|
15
|
+
delete experimental[key];
|
|
16
|
+
log.warn(
|
|
17
|
+
`Option "experimental.${key}" is no longer experimental and has moved to "${key}". Please update your Svelte or Vite config.`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
config(config, log) {
|
|
22
|
+
const using = config.plugins.filter(
|
|
23
|
+
(plugin) => (plugin?.api as { sveltePreprocess?: unknown } | undefined)?.sveltePreprocess
|
|
24
|
+
);
|
|
25
|
+
if (using.length === 0) return;
|
|
26
|
+
log.error.once(
|
|
27
|
+
`The following vite plugins use the removed 'plugin.api.sveltePreprocess' api: ${using.map((plugin) => plugin.name).join(', ')}
|
|
28
|
+
These preprocessors are no longer added to your svelte config and if your application depends on them it breaks.
|
|
29
|
+
Update the plugins or contact their maintainers. See ${transformLink} for more information.
|
|
30
|
+
`.replace(/\t+/g, '\t')
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createPlugin,
|
|
3
|
+
type Config,
|
|
4
|
+
type ExperimentalOptions,
|
|
5
|
+
type PluginFactory,
|
|
6
|
+
type PluginOptions as ProductPluginOptions
|
|
7
|
+
} from '@vigla/vite-plugin';
|
|
8
|
+
import type { UserConfig } from 'vite';
|
|
9
|
+
import { history } from './history.ts';
|
|
10
|
+
import { messages } from './messages.ts';
|
|
11
|
+
import { names } from './names.ts';
|
|
12
|
+
|
|
13
|
+
export { vitePreprocess } from '@vigla/vite-plugin';
|
|
14
|
+
export type { VitePreprocessOptions } from '@vigla/vite-plugin';
|
|
15
|
+
|
|
16
|
+
export interface ExperimentalPluginOptions extends Omit<
|
|
17
|
+
ExperimentalOptions,
|
|
18
|
+
'disableResolveWarnings'
|
|
19
|
+
> {
|
|
20
|
+
disableSvelteResolveWarnings?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface PluginOptions extends Omit<
|
|
24
|
+
ProductPluginOptions,
|
|
25
|
+
'prebundleLibraries' | 'experimental'
|
|
26
|
+
> {
|
|
27
|
+
prebundleSvelteLibraries?: boolean;
|
|
28
|
+
experimental?: ExperimentalPluginOptions;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SvelteConfig extends Omit<Config, 'vitePlugin'> {
|
|
32
|
+
vitePlugin?: PluginOptions;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface Options extends Omit<SvelteConfig, 'vitePlugin'>, PluginOptions {
|
|
36
|
+
configFile?: string | false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type LoadedSvelteConfig = Partial<SvelteConfig> & { configFile?: string };
|
|
40
|
+
|
|
41
|
+
export const svelte: PluginFactory<Options> = createPlugin<Options>({
|
|
42
|
+
name: 'vite-plugin-svelte',
|
|
43
|
+
names,
|
|
44
|
+
messages,
|
|
45
|
+
history
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export function loadSvelteConfig(
|
|
49
|
+
viteConfig?: UserConfig,
|
|
50
|
+
inline?: Partial<Options>
|
|
51
|
+
): Promise<LoadedSvelteConfig | undefined> {
|
|
52
|
+
return svelte.loadConfig(viteConfig, inline, 'svelte.config') as Promise<
|
|
53
|
+
LoadedSvelteConfig | undefined
|
|
54
|
+
>;
|
|
55
|
+
}
|
package/src/messages.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Messages } from '@vigla/vite-plugin';
|
|
2
|
+
|
|
3
|
+
export const messages: Messages = {
|
|
4
|
+
configChangeDetected:
|
|
5
|
+
'Svelte config change detected, restart your dev process to apply the changes.',
|
|
6
|
+
configChanged: (file) => `svelte config changed: restarting vite server. - file: ${file}`,
|
|
7
|
+
noClientEnvironment:
|
|
8
|
+
'No client environment found, not adding watchers for svelte config and preprocessor dependencies',
|
|
9
|
+
configNotFound: (file) => `failed to find svelte config file ${file}.`,
|
|
10
|
+
configAbsent: (root) => `no Svelte config found at ${root} - using default configuration.`,
|
|
11
|
+
configsMultiple: (file) =>
|
|
12
|
+
`found more than one svelte config file, using ${file}. you should only have one!`,
|
|
13
|
+
optionsMisplaced: (keys) =>
|
|
14
|
+
`Invalid options in svelte config. Move the following options into 'vitePlugin:{...}': ${keys}`,
|
|
15
|
+
optionsAtRoot: (keys) =>
|
|
16
|
+
`Invalid options in svelte config under vitePlugin:{...}', move them to the config root : ${keys}`,
|
|
17
|
+
optionsDuplicate: (keys) =>
|
|
18
|
+
`Invalid duplicate options in svelte config under vitePlugin:{...}', they are defined in root too and must only exist once: ${keys}`,
|
|
19
|
+
optionsUnknown: (keys) =>
|
|
20
|
+
`ignoring unknown plugin options in svelte config under vitePlugin:{...}: ${keys}`,
|
|
21
|
+
cssHash: 'The custom compilerOptions.cssHash in your svelte config can degrade your DX.',
|
|
22
|
+
controlledOptions: (plugin, keys) =>
|
|
23
|
+
`The following Svelte compilerOptions are controlled by ${plugin} and essential to its functionality. User-specified values are ignored. Please remove them from your configuration: ${keys}`,
|
|
24
|
+
missingCondition: () =>
|
|
25
|
+
'The following packages have a svelte field in their package.json but no exports condition for svelte.'
|
|
26
|
+
};
|
package/src/names.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Names } from '@vigla/vite-plugin';
|
|
2
|
+
|
|
3
|
+
const docs = 'https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs';
|
|
4
|
+
|
|
5
|
+
export const names: Partial<Names> = {
|
|
6
|
+
prebundle: 'prebundleSvelteLibraries',
|
|
7
|
+
resolveWarnings: 'disableSvelteResolveWarnings',
|
|
8
|
+
warningsEvent: 'svelte:warnings',
|
|
9
|
+
styleFlag: 'svelte',
|
|
10
|
+
metaKey: 'svelte',
|
|
11
|
+
metadataFile: '_svelte_metadata.json',
|
|
12
|
+
withoutSources: [
|
|
13
|
+
'@sveltejs/kit',
|
|
14
|
+
'@sveltejs/package',
|
|
15
|
+
'@sveltejs/vite-plugin-svelte',
|
|
16
|
+
'svelte2tsx',
|
|
17
|
+
'svelte-check',
|
|
18
|
+
'svelte-preprocess'
|
|
19
|
+
],
|
|
20
|
+
withoutSourcesPrefixes: ['@sveltejs/adapter-'],
|
|
21
|
+
links: {
|
|
22
|
+
cssHash: `${docs}/faq.md#why-should-csshash-be-calculated-from-filename-during-dev`,
|
|
23
|
+
preprocess: `${docs}/preprocess.md`,
|
|
24
|
+
missingCondition: `${docs}/faq.md#missing-exports-condition`
|
|
25
|
+
}
|
|
26
|
+
};
|
package/README.md
DELETED