@@ -8,7 +8,7 @@ import * as w from './warnings.js';
8
8
* @typedef {(input: Input, keypath: string) => Required<Output> } Validator
9
9
*/
10
10
11
- const common = {
11
+ const common_options = {
12
12
filename : string ( '(unknown)' ) ,
13
13
14
14
// default to process.cwd() where it exists to replicate svelte4 behavior (and make Deno work with this as well)
@@ -44,110 +44,120 @@ const common = {
44
44
warningFilter : fun ( ( ) => true )
45
45
} ;
46
46
47
- export const validate_module_options =
48
- /** @type {Validator<ModuleCompileOptions, ValidatedModuleCompileOptions> } */ (
49
- object ( {
50
- ...common
51
- } )
52
- ) ;
47
+ const component_options = {
48
+ accessors : deprecate ( w . options_deprecated_accessors , boolean ( false ) ) ,
53
49
54
- export const validate_component_options =
55
- /** @type {Validator<CompileOptions, ValidatedCompileOptions> } */ (
56
- object ( {
57
- ...common ,
50
+ css : validator ( 'external' , ( input ) => {
51
+ if ( input === true || input === false ) {
52
+ throw_error (
53
+ 'The boolean options have been removed from the css option. Use "external" instead of false and "injected" instead of true'
54
+ ) ;
55
+ }
56
+ if ( input === 'none' ) {
57
+ throw_error (
58
+ 'css: "none" is no longer a valid option. If this was crucial for you, please open an issue on GitHub with your use case.'
59
+ ) ;
60
+ }
58
61
59
- accessors : deprecate ( w . options_deprecated_accessors , boolean ( false ) ) ,
62
+ if ( input !== 'external' && input !== 'injected' ) {
63
+ throw_error ( `css should be either "external" (default, recommended) or "injected"` ) ;
64
+ }
60
65
61
- css : validator ( 'external' , ( input ) => {
62
- if ( input === true || input === false ) {
63
- throw_error (
64
- 'The boolean options have been removed from the css option. Use "external" instead of false and "injected" instead of true'
65
- ) ;
66
- }
67
- if ( input === 'none' ) {
68
- throw_error (
69
- 'css: "none" is no longer a valid option. If this was crucial for you, please open an issue on GitHub with your use case.'
70
- ) ;
71
- }
66
+ return input ;
67
+ } ) ,
72
68
73
- if ( input !== 'external' && input !== 'injected' ) {
74
- throw_error ( `css should be either "external" (default, recommended) or "injected"` ) ;
75
- }
69
+ cssHash : fun ( ( { css, hash } ) => {
70
+ return `svelte-${ hash ( css ) } ` ;
71
+ } ) ,
72
+
73
+ // TODO this is a sourcemap option, would be good to put under a sourcemap namespace
74
+ cssOutputFilename : string ( undefined ) ,
75
+
76
+ customElement : boolean ( false ) ,
77
+
78
+ discloseVersion : boolean ( true ) ,
76
79
77
- return input ;
78
- } ) ,
80
+ immutable : deprecate ( w . options_deprecated_immutable , boolean ( false ) ) ,
79
81
80
- cssHash : fun ( ( { css, hash } ) => {
81
- return `svelte-${ hash ( css ) } ` ;
82
- } ) ,
82
+ legacy : removed (
83
+ 'The legacy option has been removed. If you are using this because of legacy.componentApi, use compatibility.componentApi instead'
84
+ ) ,
85
+
86
+ compatibility : object ( {
87
+ componentApi : list ( [ 4 , 5 ] , 5 )
88
+ } ) ,
89
+
90
+ loopGuardTimeout : warn_removed ( w . options_removed_loop_guard_timeout ) ,
91
+
92
+ name : string ( undefined ) ,
83
93
84
- // TODO this is a sourcemap option, would be good to put under a sourcemap namespace
85
- cssOutputFilename : string ( undefined ) ,
94
+ namespace : list ( [ 'html' , 'mathml' , 'svg' ] ) ,
86
95
87
- customElement : boolean ( false ) ,
96
+ modernAst : boolean ( false ) ,
88
97
89
- discloseVersion : boolean ( true ) ,
98
+ outputFilename : string ( undefined ) ,
90
99
91
- immutable : deprecate ( w . options_deprecated_immutable , boolean ( false ) ) ,
100
+ preserveComments : boolean ( false ) ,
92
101
93
- legacy : removed (
94
- 'The legacy option has been removed. If you are using this because of legacy.componentApi, use compatibility.componentApi instead'
95
- ) ,
102
+ fragments : list ( [ 'html' , 'tree' ] ) ,
96
103
97
- compatibility : object ( {
98
- componentApi : list ( [ 4 , 5 ] , 5 )
99
- } ) ,
104
+ preserveWhitespace : boolean ( false ) ,
100
105
101
- loopGuardTimeout : warn_removed ( w . options_removed_loop_guard_timeout ) ,
106
+ runes : boolean ( undefined ) ,
102
107
103
- name : string ( undefined ) ,
108
+ hmr : boolean ( false ) ,
104
109
105
- namespace : list ( [ 'html' , 'mathml' , 'svg' ] ) ,
110
+ sourcemap : validator ( undefined , ( input ) => {
111
+ // Source maps can take on a variety of values, including string, JSON, map objects from magic-string and source-map,
112
+ // so there's no good way to check type validity here
113
+ return input ;
114
+ } ) ,
106
115
107
- modernAst : boolean ( false ) ,
116
+ enableSourcemap : warn_removed ( w . options_removed_enable_sourcemap ) ,
108
117
109
- outputFilename : string ( undefined ) ,
118
+ hydratable : warn_removed ( w . options_removed_hydratable ) ,
110
119
111
- preserveComments : boolean ( false ) ,
120
+ format : removed (
121
+ 'The format option has been removed in Svelte 4, the compiler only outputs ESM now. Remove "format" from your compiler options. ' +
122
+ 'If you did not set this yourself, bump the version of your bundler plugin (vite-plugin-svelte/rollup-plugin-svelte/svelte-loader)'
123
+ ) ,
112
124
113
- fragments : list ( [ 'html' , 'tree' ] ) ,
125
+ tag : removed (
126
+ 'The tag option has been removed in Svelte 5. Use `<svelte:options customElement="tag-name" />` inside the component instead. ' +
127
+ 'If that does not solve your use case, please open an issue on GitHub with details.'
128
+ ) ,
114
129
115
- preserveWhitespace : boolean ( false ) ,
130
+ sveltePath : removed (
131
+ 'The sveltePath option has been removed in Svelte 5. ' +
132
+ 'If this option was crucial for you, please open an issue on GitHub with your use case.'
133
+ ) ,
116
134
117
- runes : boolean ( undefined ) ,
135
+ // These two were primarily created for svelte-preprocess (https://github.com/sveltejs/svelte/pull/6194),
136
+ // but with new TypeScript compilation modes strictly separating types it's not necessary anymore
137
+ errorMode : removed (
138
+ 'The errorMode option has been removed. If you are using this through svelte-preprocess with TypeScript, ' +
139
+ 'use the https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax setting instead'
140
+ ) ,
118
141
119
- hmr : boolean ( false ) ,
142
+ varsReport : removed (
143
+ 'The vars option has been removed. If you are using this through svelte-preprocess with TypeScript, ' +
144
+ 'use the https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax setting instead'
145
+ )
146
+ } ;
120
147
121
- sourcemap : validator ( undefined , ( input ) => {
122
- // Source maps can take on a variety of values, including string, JSON, map objects from magic-string and source-map,
123
- // so there's no good way to check type validity here
124
- return input ;
125
- } ) ,
148
+ export const validate_module_options =
149
+ /** @type {Validator<ModuleCompileOptions, ValidatedModuleCompileOptions> } */ (
150
+ object ( {
151
+ ...common_options ,
152
+ ...Object . fromEntries ( Object . keys ( component_options ) . map ( ( key ) => [ key , ( ) => { } ] ) )
153
+ } )
154
+ ) ;
126
155
127
- enableSourcemap : warn_removed ( w . options_removed_enable_sourcemap ) ,
128
- hydratable : warn_removed ( w . options_removed_hydratable ) ,
129
- format : removed (
130
- 'The format option has been removed in Svelte 4, the compiler only outputs ESM now. Remove "format" from your compiler options. ' +
131
- 'If you did not set this yourself, bump the version of your bundler plugin (vite-plugin-svelte/rollup-plugin-svelte/svelte-loader)'
132
- ) ,
133
- tag : removed (
134
- 'The tag option has been removed in Svelte 5. Use `<svelte:options customElement="tag-name" />` inside the component instead. ' +
135
- 'If that does not solve your use case, please open an issue on GitHub with details.'
136
- ) ,
137
- sveltePath : removed (
138
- 'The sveltePath option has been removed in Svelte 5. ' +
139
- 'If this option was crucial for you, please open an issue on GitHub with your use case.'
140
- ) ,
141
- // These two were primarily created for svelte-preprocess (https://github.com/sveltejs/svelte/pull/6194),
142
- // but with new TypeScript compilation modes strictly separating types it's not necessary anymore
143
- errorMode : removed (
144
- 'The errorMode option has been removed. If you are using this through svelte-preprocess with TypeScript, ' +
145
- 'use the https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax setting instead'
146
- ) ,
147
- varsReport : removed (
148
- 'The vars option has been removed. If you are using this through svelte-preprocess with TypeScript, ' +
149
- 'use the https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax setting instead'
150
- )
156
+ export const validate_component_options =
157
+ /** @type {Validator<CompileOptions, ValidatedCompileOptions> } */ (
158
+ object ( {
159
+ ...common_options ,
160
+ ...component_options
151
161
} )
152
162
) ;
153
163
0 commit comments