@@ -69,6 +69,7 @@ export default class Component {
69
69
reactive_declaration_nodes : Set < Node > = new Set ( ) ;
70
70
has_reactive_assignments = false ;
71
71
injected_reactive_declaration_vars : Set < string > = new Set ( ) ;
72
+ helpers : Set < string > = new Set ( ) ;
72
73
73
74
indirectDependencies : Map < string , Set < string > > = new Map ( ) ;
74
75
@@ -114,10 +115,6 @@ export default class Component {
114
115
this . componentOptions = process_component_options ( this , this . ast . html . children ) ;
115
116
this . namespace = namespaces [ this . componentOptions . namespace ] || this . componentOptions . namespace ;
116
117
117
- if ( this . componentOptions . props ) {
118
- this . has_reactive_assignments = true ;
119
- }
120
-
121
118
if ( compileOptions . customElement === true && ! this . componentOptions . tag ) {
122
119
throw new Error ( `No tag name specified` ) ; // TODO better error
123
120
}
@@ -131,6 +128,13 @@ export default class Component {
131
128
this . walk_module_js ( ) ;
132
129
this . walk_instance_js_pre_template ( ) ;
133
130
131
+ if ( this . componentOptions . props ) {
132
+ this . has_reactive_assignments = true ;
133
+
134
+ const variable = this . var_lookup . get ( this . componentOptions . props_object ) ;
135
+ variable . reassigned = true ;
136
+ }
137
+
134
138
this . name = this . getUniqueName ( name ) ;
135
139
this . fragment = new Fragment ( this , ast . html ) ;
136
140
@@ -196,14 +200,12 @@ export default class Component {
196
200
197
201
const banner = `/* ${ this . file ? `${ this . file } ` : `` } generated by Svelte v${ "__VERSION__" } */` ;
198
202
199
- const helpers = new Set ( ) ;
200
-
201
203
// TODO use same regex for both
202
204
result = result . replace ( compileOptions . generate === 'ssr' ? / ( @ + | # + ) ( \w * (?: - \w * ) ? ) / g : / ( @ + ) ( \w * (?: - \w * ) ? ) / g, ( match : string , sigil : string , name : string ) => {
203
205
if ( sigil === '@' ) {
204
206
if ( internal_exports . has ( name ) ) {
205
207
if ( compileOptions . dev && internal_exports . has ( `${ name } Dev` ) ) name = `${ name } Dev` ;
206
- helpers . add ( name ) ;
208
+ this . helpers . add ( name ) ;
207
209
}
208
210
209
211
return this . alias ( name ) ;
@@ -212,7 +214,7 @@ export default class Component {
212
214
return sigil . slice ( 1 ) + name ;
213
215
} ) ;
214
216
215
- const importedHelpers = Array . from ( helpers )
217
+ const importedHelpers = Array . from ( this . helpers )
216
218
. sort ( )
217
219
. map ( name => {
218
220
const alias = this . alias ( name ) ;
@@ -761,9 +763,14 @@ export default class Component {
761
763
} ) ;
762
764
}
763
765
766
+ // can't use the @ trick here, because we're
767
+ // manipulating the underlying magic string
768
+ component . helpers . add ( 'exclude_internal_props' ) ;
769
+ const exclude_internal_props = component . alias ( 'exclude_internal_props' ) ;
770
+
764
771
const suffix = code . original [ declarator . end ] === ';'
765
- ? ` = $$ props`
766
- : ` = $$ props;`
772
+ ? ` = ${ exclude_internal_props } ($$ props) `
773
+ : ` = ${ exclude_internal_props } ($$ props) ;`
767
774
768
775
if ( declarator . id . end === declarator . end ) {
769
776
code . appendLeft ( declarator . end , suffix ) ;
0 commit comments