Skip to content

Commit 198dbcf

Browse files
committed
chore: warn on passed format option
1 parent a3f52f9 commit 198dbcf

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/compiler/compile/index.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import get_name_from_filename from './utils/get_name_from_filename.js';
88
import { valid_namespaces } from '../utils/namespaces.js';
99

1010
const valid_options = [
11-
'format',
1211
'name',
1312
'filename',
1413
'sourcemap',
@@ -37,11 +36,24 @@ const valid_css_values = [true, false, 'injected', 'external', 'none'];
3736
const regex_valid_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
3837
const regex_starts_with_lowercase_character = /^[a-z]/;
3938

39+
let warned_of_format = false;
40+
4041
/**
4142
* @param {import('../interfaces.js').CompileOptions} options
4243
* @param {import('../interfaces.js').Warning[]} warnings
4344
*/
4445
function validate_options(options, warnings) {
46+
if (/** @type {any} */ (options).format) {
47+
if (!warned_of_format) {
48+
warned_of_format = true;
49+
console.warn(
50+
'The format option has been removed in Svelte 4, the compiler only outputs ESM now. Remove "format" from your compiler options. ' +
51+
'If you did not set this yourself, bump the version of your bundler plugin (vite-plugin-svelte/rollup-plugin-svelte/svelte-loader)'
52+
);
53+
}
54+
delete (/** @type {any} */ (options).format);
55+
}
56+
4557
const { name, filename, loopGuardTimeout, dev, namespace, css } = options;
4658
Object.keys(options).forEach(
4759
/** @param {any} key */ (key) => {

0 commit comments

Comments
 (0)