svelte 3.46.2 → 3.46.3
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/CHANGELOG.md +6 -0
- package/compiler.js +52 -27
- package/compiler.js.map +1 -1
- package/compiler.mjs +52 -27
- package/compiler.mjs.map +1 -1
- package/internal/index.js +1 -1
- package/internal/index.mjs +1 -1
- package/package.json +1 -1
- package/types/compiler/compile/Component.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Svelte changelog
|
|
2
2
|
|
|
3
|
+
## 3.46.3
|
|
4
|
+
|
|
5
|
+
* Ignore whitespace in `{#each}` blocks when containing elements with `animate:` ([#5477](https://github.com/sveltejs/svelte/pull/5477))
|
|
6
|
+
* Throw compiler error when variable in `context="instance"` collides with import in `context="module"` ([#7090](https://github.com/sveltejs/svelte/issues/7090))
|
|
7
|
+
* Fix compiler crash when `{@const}` contains arrow functions ([#7134](https://github.com/sveltejs/svelte/issues/7134))
|
|
8
|
+
|
|
3
9
|
## 3.46.2
|
|
4
10
|
|
|
5
11
|
* Export `FlipParams` interface from `svelte/animate` ([#7103](https://github.com/sveltejs/svelte/issues/7103))
|
package/compiler.js
CHANGED
|
@@ -19044,6 +19044,10 @@
|
|
|
19044
19044
|
code: 'illegal-global',
|
|
19045
19045
|
message: `${name} is an illegal variable name`
|
|
19046
19046
|
}),
|
|
19047
|
+
illegal_variable_declaration: {
|
|
19048
|
+
code: 'illegal-variable-declaration',
|
|
19049
|
+
message: 'Cannot declare same variable name which is imported inside <script context="module">'
|
|
19050
|
+
},
|
|
19047
19051
|
cyclical_reactive_declaration: (cycle) => ({
|
|
19048
19052
|
code: 'cyclical-reactive-declaration',
|
|
19049
19053
|
message: `Cyclical dependency detected: ${cycle.join(' → ')}`
|
|
@@ -19186,7 +19190,7 @@
|
|
|
19186
19190
|
if (!lazy) {
|
|
19187
19191
|
dependencies.add(name);
|
|
19188
19192
|
}
|
|
19189
|
-
component.add_reference(name);
|
|
19193
|
+
component.add_reference(node, name);
|
|
19190
19194
|
component.warn_if_undefined(name, nodes[0], template_scope);
|
|
19191
19195
|
}
|
|
19192
19196
|
this.skip();
|
|
@@ -19218,7 +19222,7 @@
|
|
|
19218
19222
|
each_block.has_binding = true;
|
|
19219
19223
|
}
|
|
19220
19224
|
else {
|
|
19221
|
-
component.add_reference(name);
|
|
19225
|
+
component.add_reference(node, name);
|
|
19222
19226
|
const variable = component.var_lookup.get(name);
|
|
19223
19227
|
if (variable)
|
|
19224
19228
|
variable[deep ? 'mutated' : 'reassigned'] = true;
|
|
@@ -19279,7 +19283,7 @@
|
|
|
19279
19283
|
}
|
|
19280
19284
|
else {
|
|
19281
19285
|
dependencies.add(name);
|
|
19282
|
-
component.add_reference(name); // TODO is this redundant/misplaced?
|
|
19286
|
+
component.add_reference(node, name); // TODO is this redundant/misplaced?
|
|
19283
19287
|
}
|
|
19284
19288
|
}
|
|
19285
19289
|
else if (is_contextual(component, template_scope, name)) {
|
|
@@ -19303,11 +19307,20 @@
|
|
|
19303
19307
|
if (node === function_expression) {
|
|
19304
19308
|
const id = component.get_unique_name(sanitize(get_function_name(node, owner)));
|
|
19305
19309
|
const declaration = b `const ${id} = ${node}`;
|
|
19306
|
-
if (
|
|
19310
|
+
if (owner.type === 'ConstTag') {
|
|
19311
|
+
walk(node, {
|
|
19312
|
+
enter(node) {
|
|
19313
|
+
if (node.type === 'Identifier') {
|
|
19314
|
+
this.replace(block.renderer.reference(node, ctx));
|
|
19315
|
+
}
|
|
19316
|
+
}
|
|
19317
|
+
});
|
|
19318
|
+
}
|
|
19319
|
+
else if (dependencies.size === 0 && contextual_dependencies.size === 0) {
|
|
19307
19320
|
// we can hoist this out of the component completely
|
|
19308
19321
|
component.fully_hoisted.push(declaration);
|
|
19309
19322
|
this.replace(id);
|
|
19310
|
-
component.add_var({
|
|
19323
|
+
component.add_var(node, {
|
|
19311
19324
|
name: id.name,
|
|
19312
19325
|
internal: true,
|
|
19313
19326
|
hoistable: true,
|
|
@@ -19572,7 +19585,7 @@
|
|
|
19572
19585
|
if (is_reference(node, parent)) {
|
|
19573
19586
|
const { name } = flatten_reference(node);
|
|
19574
19587
|
if (!scope.is_let(name) && !scope.names.has(name)) {
|
|
19575
|
-
component.add_reference(name);
|
|
19588
|
+
component.add_reference(node, name);
|
|
19576
19589
|
}
|
|
19577
19590
|
}
|
|
19578
19591
|
}
|
|
@@ -19724,7 +19737,7 @@
|
|
|
19724
19737
|
const object = info.name.split('.')[0];
|
|
19725
19738
|
component.warn_if_undefined(object, info, scope);
|
|
19726
19739
|
this.name = info.name;
|
|
19727
|
-
component.add_reference(object);
|
|
19740
|
+
component.add_reference(this, object);
|
|
19728
19741
|
this.expression = info.expression
|
|
19729
19742
|
? new Expression(component, this, scope, info.expression)
|
|
19730
19743
|
: null;
|
|
@@ -19791,6 +19804,7 @@
|
|
|
19791
19804
|
this.has_animation = false;
|
|
19792
19805
|
([this.const_tags, this.children] = get_const_tags(info.children, component, this, this));
|
|
19793
19806
|
if (this.has_animation) {
|
|
19807
|
+
this.children = this.children.filter(child => !isEmptyNode(child));
|
|
19794
19808
|
if (this.children.length !== 1) {
|
|
19795
19809
|
const child = this.children.find(child => !!child.animation);
|
|
19796
19810
|
component.error(child.animation, compiler_errors.invalid_animation_sole);
|
|
@@ -19803,6 +19817,9 @@
|
|
|
19803
19817
|
: null;
|
|
19804
19818
|
}
|
|
19805
19819
|
}
|
|
19820
|
+
function isEmptyNode(node) {
|
|
19821
|
+
return node.type === 'Text' && node.data.trim() === '';
|
|
19822
|
+
}
|
|
19806
19823
|
|
|
19807
19824
|
function string_literal(data) {
|
|
19808
19825
|
return {
|
|
@@ -19985,7 +20002,7 @@
|
|
|
19985
20002
|
super(component, parent, scope, info);
|
|
19986
20003
|
component.warn_if_undefined(info.name, info, scope);
|
|
19987
20004
|
this.name = info.name;
|
|
19988
|
-
component.add_reference(info.name.split('.')[0]);
|
|
20005
|
+
component.add_reference(this, info.name.split('.')[0]);
|
|
19989
20006
|
this.directive = info.intro && info.outro ? 'transition' : info.intro ? 'in' : 'out';
|
|
19990
20007
|
this.is_local = info.modifiers.includes('local');
|
|
19991
20008
|
if ((info.intro && parent.intro) || (info.outro && parent.outro)) {
|
|
@@ -20004,7 +20021,7 @@
|
|
|
20004
20021
|
super(component, parent, scope, info);
|
|
20005
20022
|
component.warn_if_undefined(info.name, info, scope);
|
|
20006
20023
|
this.name = info.name;
|
|
20007
|
-
component.add_reference(info.name.split('.')[0]);
|
|
20024
|
+
component.add_reference(this, info.name.split('.')[0]);
|
|
20008
20025
|
if (parent.animation) {
|
|
20009
20026
|
component.error(this, compiler_errors.duplicate_animation);
|
|
20010
20027
|
return;
|
|
@@ -20947,7 +20964,7 @@
|
|
|
20947
20964
|
if (info.name !== 'svelte:component' && info.name !== 'svelte:self') {
|
|
20948
20965
|
const name = info.name.split('.')[0]; // accommodate namespaces
|
|
20949
20966
|
component.warn_if_undefined(name, info, scope);
|
|
20950
|
-
component.add_reference(name);
|
|
20967
|
+
component.add_reference(this, name);
|
|
20951
20968
|
}
|
|
20952
20969
|
this.name = info.name;
|
|
20953
20970
|
this.expression = this.name === 'svelte:component'
|
|
@@ -25953,7 +25970,7 @@
|
|
|
25953
25970
|
const member = this.context_lookup.get(name);
|
|
25954
25971
|
// TODO is this correct?
|
|
25955
25972
|
if (this.component.var_lookup.get(name)) {
|
|
25956
|
-
this.component.add_reference(name);
|
|
25973
|
+
this.component.add_reference(node, name);
|
|
25957
25974
|
}
|
|
25958
25975
|
if (member !== undefined) {
|
|
25959
25976
|
const replacement = x `/*${member.name}*/ ${ctx}[${member.index}]`;
|
|
@@ -30617,26 +30634,32 @@
|
|
|
30617
30634
|
this.stylesheet.reify();
|
|
30618
30635
|
this.stylesheet.warn_on_unused_selectors(this);
|
|
30619
30636
|
}
|
|
30620
|
-
add_var(variable, add_to_lookup = true) {
|
|
30637
|
+
add_var(node, variable, add_to_lookup = true) {
|
|
30621
30638
|
this.vars.push(variable);
|
|
30622
30639
|
if (add_to_lookup) {
|
|
30640
|
+
if (this.var_lookup.has(variable.name)) {
|
|
30641
|
+
const exists_var = this.var_lookup.get(variable.name);
|
|
30642
|
+
if (exists_var.module && exists_var.imported) {
|
|
30643
|
+
this.error(node, compiler_errors.illegal_variable_declaration);
|
|
30644
|
+
}
|
|
30645
|
+
}
|
|
30623
30646
|
this.var_lookup.set(variable.name, variable);
|
|
30624
30647
|
}
|
|
30625
30648
|
}
|
|
30626
|
-
add_reference(name) {
|
|
30649
|
+
add_reference(node, name) {
|
|
30627
30650
|
const variable = this.var_lookup.get(name);
|
|
30628
30651
|
if (variable) {
|
|
30629
30652
|
variable.referenced = true;
|
|
30630
30653
|
}
|
|
30631
30654
|
else if (is_reserved_keyword(name)) {
|
|
30632
|
-
this.add_var({
|
|
30655
|
+
this.add_var(node, {
|
|
30633
30656
|
name,
|
|
30634
30657
|
injected: true,
|
|
30635
30658
|
referenced: true
|
|
30636
30659
|
});
|
|
30637
30660
|
}
|
|
30638
30661
|
else if (name[0] === '$') {
|
|
30639
|
-
this.add_var({
|
|
30662
|
+
this.add_var(node, {
|
|
30640
30663
|
name,
|
|
30641
30664
|
injected: true,
|
|
30642
30665
|
referenced: true,
|
|
@@ -30652,7 +30675,7 @@
|
|
|
30652
30675
|
}
|
|
30653
30676
|
else {
|
|
30654
30677
|
if (this.compile_options.varsReport === 'full') {
|
|
30655
|
-
this.add_var({ name, referenced: true }, false);
|
|
30678
|
+
this.add_var(node, { name, referenced: true }, false);
|
|
30656
30679
|
}
|
|
30657
30680
|
this.used_names.add(name);
|
|
30658
30681
|
}
|
|
@@ -30677,7 +30700,7 @@
|
|
|
30677
30700
|
if (result) {
|
|
30678
30701
|
const { compile_options, name } = this;
|
|
30679
30702
|
const { format = 'esm' } = compile_options;
|
|
30680
|
-
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.46.
|
|
30703
|
+
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.46.3'}`;
|
|
30681
30704
|
const program = { type: 'Program', body: result.js };
|
|
30682
30705
|
walk(program, {
|
|
30683
30706
|
enter: (node, parent, key) => {
|
|
@@ -30951,11 +30974,13 @@
|
|
|
30951
30974
|
return this.error(node, compiler_errors.illegal_declaration);
|
|
30952
30975
|
}
|
|
30953
30976
|
const writable = node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let');
|
|
30954
|
-
|
|
30977
|
+
const imported = node.type.startsWith('Import');
|
|
30978
|
+
this.add_var(node, {
|
|
30955
30979
|
name,
|
|
30956
30980
|
module: true,
|
|
30957
30981
|
hoistable: true,
|
|
30958
|
-
writable
|
|
30982
|
+
writable,
|
|
30983
|
+
imported
|
|
30959
30984
|
});
|
|
30960
30985
|
});
|
|
30961
30986
|
globals.forEach((node, name) => {
|
|
@@ -30963,7 +30988,7 @@
|
|
|
30963
30988
|
return this.error(node, compiler_errors.illegal_subscription);
|
|
30964
30989
|
}
|
|
30965
30990
|
else {
|
|
30966
|
-
this.add_var({
|
|
30991
|
+
this.add_var(node, {
|
|
30967
30992
|
name,
|
|
30968
30993
|
global: true,
|
|
30969
30994
|
hoistable: true
|
|
@@ -31019,7 +31044,7 @@
|
|
|
31019
31044
|
}
|
|
31020
31045
|
const writable = node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let');
|
|
31021
31046
|
const imported = node.type.startsWith('Import');
|
|
31022
|
-
this.add_var({
|
|
31047
|
+
this.add_var(node, {
|
|
31023
31048
|
name,
|
|
31024
31049
|
initialised: instance_scope.initialised_declarations.has(name),
|
|
31025
31050
|
writable,
|
|
@@ -31039,7 +31064,7 @@
|
|
|
31039
31064
|
return;
|
|
31040
31065
|
const node = globals.get(name);
|
|
31041
31066
|
if (this.injected_reactive_declaration_vars.has(name)) {
|
|
31042
|
-
this.add_var({
|
|
31067
|
+
this.add_var(node, {
|
|
31043
31068
|
name,
|
|
31044
31069
|
injected: true,
|
|
31045
31070
|
writable: true,
|
|
@@ -31048,7 +31073,7 @@
|
|
|
31048
31073
|
});
|
|
31049
31074
|
}
|
|
31050
31075
|
else if (is_reserved_keyword(name)) {
|
|
31051
|
-
this.add_var({
|
|
31076
|
+
this.add_var(node, {
|
|
31052
31077
|
name,
|
|
31053
31078
|
injected: true
|
|
31054
31079
|
});
|
|
@@ -31057,13 +31082,13 @@
|
|
|
31057
31082
|
if (name === '$' || name[1] === '$') {
|
|
31058
31083
|
return this.error(node, compiler_errors.illegal_global(name));
|
|
31059
31084
|
}
|
|
31060
|
-
this.add_var({
|
|
31085
|
+
this.add_var(node, {
|
|
31061
31086
|
name,
|
|
31062
31087
|
injected: true,
|
|
31063
31088
|
mutated: true,
|
|
31064
31089
|
writable: true
|
|
31065
31090
|
});
|
|
31066
|
-
this.add_reference(name.slice(1));
|
|
31091
|
+
this.add_reference(node, name.slice(1));
|
|
31067
31092
|
const variable = this.var_lookup.get(name.slice(1));
|
|
31068
31093
|
if (variable) {
|
|
31069
31094
|
variable.subscribable = true;
|
|
@@ -31071,7 +31096,7 @@
|
|
|
31071
31096
|
}
|
|
31072
31097
|
}
|
|
31073
31098
|
else {
|
|
31074
|
-
this.add_var({
|
|
31099
|
+
this.add_var(node, {
|
|
31075
31100
|
name,
|
|
31076
31101
|
global: true,
|
|
31077
31102
|
hoistable: true
|
|
@@ -32168,7 +32193,7 @@
|
|
|
32168
32193
|
return result.to_processed();
|
|
32169
32194
|
}
|
|
32170
32195
|
|
|
32171
|
-
const VERSION = '3.46.
|
|
32196
|
+
const VERSION = '3.46.3';
|
|
32172
32197
|
|
|
32173
32198
|
exports.VERSION = VERSION;
|
|
32174
32199
|
exports.compile = compile;
|