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