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/compiler.mjs
CHANGED
|
@@ -19038,6 +19038,10 @@ var compiler_errors = {
|
|
|
19038
19038
|
code: 'illegal-global',
|
|
19039
19039
|
message: `${name} is an illegal variable name`
|
|
19040
19040
|
}),
|
|
19041
|
+
illegal_variable_declaration: {
|
|
19042
|
+
code: 'illegal-variable-declaration',
|
|
19043
|
+
message: 'Cannot declare same variable name which is imported inside <script context="module">'
|
|
19044
|
+
},
|
|
19041
19045
|
cyclical_reactive_declaration: (cycle) => ({
|
|
19042
19046
|
code: 'cyclical-reactive-declaration',
|
|
19043
19047
|
message: `Cyclical dependency detected: ${cycle.join(' → ')}`
|
|
@@ -19180,7 +19184,7 @@ class Expression {
|
|
|
19180
19184
|
if (!lazy) {
|
|
19181
19185
|
dependencies.add(name);
|
|
19182
19186
|
}
|
|
19183
|
-
component.add_reference(name);
|
|
19187
|
+
component.add_reference(node, name);
|
|
19184
19188
|
component.warn_if_undefined(name, nodes[0], template_scope);
|
|
19185
19189
|
}
|
|
19186
19190
|
this.skip();
|
|
@@ -19212,7 +19216,7 @@ class Expression {
|
|
|
19212
19216
|
each_block.has_binding = true;
|
|
19213
19217
|
}
|
|
19214
19218
|
else {
|
|
19215
|
-
component.add_reference(name);
|
|
19219
|
+
component.add_reference(node, name);
|
|
19216
19220
|
const variable = component.var_lookup.get(name);
|
|
19217
19221
|
if (variable)
|
|
19218
19222
|
variable[deep ? 'mutated' : 'reassigned'] = true;
|
|
@@ -19273,7 +19277,7 @@ class Expression {
|
|
|
19273
19277
|
}
|
|
19274
19278
|
else {
|
|
19275
19279
|
dependencies.add(name);
|
|
19276
|
-
component.add_reference(name); // TODO is this redundant/misplaced?
|
|
19280
|
+
component.add_reference(node, name); // TODO is this redundant/misplaced?
|
|
19277
19281
|
}
|
|
19278
19282
|
}
|
|
19279
19283
|
else if (is_contextual(component, template_scope, name)) {
|
|
@@ -19297,11 +19301,20 @@ class Expression {
|
|
|
19297
19301
|
if (node === function_expression) {
|
|
19298
19302
|
const id = component.get_unique_name(sanitize(get_function_name(node, owner)));
|
|
19299
19303
|
const declaration = b `const ${id} = ${node}`;
|
|
19300
|
-
if (
|
|
19304
|
+
if (owner.type === 'ConstTag') {
|
|
19305
|
+
walk(node, {
|
|
19306
|
+
enter(node) {
|
|
19307
|
+
if (node.type === 'Identifier') {
|
|
19308
|
+
this.replace(block.renderer.reference(node, ctx));
|
|
19309
|
+
}
|
|
19310
|
+
}
|
|
19311
|
+
});
|
|
19312
|
+
}
|
|
19313
|
+
else if (dependencies.size === 0 && contextual_dependencies.size === 0) {
|
|
19301
19314
|
// we can hoist this out of the component completely
|
|
19302
19315
|
component.fully_hoisted.push(declaration);
|
|
19303
19316
|
this.replace(id);
|
|
19304
|
-
component.add_var({
|
|
19317
|
+
component.add_var(node, {
|
|
19305
19318
|
name: id.name,
|
|
19306
19319
|
internal: true,
|
|
19307
19320
|
hoistable: true,
|
|
@@ -19566,7 +19579,7 @@ function mark_referenced(node, scope, component) {
|
|
|
19566
19579
|
if (is_reference(node, parent)) {
|
|
19567
19580
|
const { name } = flatten_reference(node);
|
|
19568
19581
|
if (!scope.is_let(name) && !scope.names.has(name)) {
|
|
19569
|
-
component.add_reference(name);
|
|
19582
|
+
component.add_reference(node, name);
|
|
19570
19583
|
}
|
|
19571
19584
|
}
|
|
19572
19585
|
}
|
|
@@ -19718,7 +19731,7 @@ class Action extends Node$1 {
|
|
|
19718
19731
|
const object = info.name.split('.')[0];
|
|
19719
19732
|
component.warn_if_undefined(object, info, scope);
|
|
19720
19733
|
this.name = info.name;
|
|
19721
|
-
component.add_reference(object);
|
|
19734
|
+
component.add_reference(this, object);
|
|
19722
19735
|
this.expression = info.expression
|
|
19723
19736
|
? new Expression(component, this, scope, info.expression)
|
|
19724
19737
|
: null;
|
|
@@ -19785,6 +19798,7 @@ class EachBlock extends AbstractBlock {
|
|
|
19785
19798
|
this.has_animation = false;
|
|
19786
19799
|
([this.const_tags, this.children] = get_const_tags(info.children, component, this, this));
|
|
19787
19800
|
if (this.has_animation) {
|
|
19801
|
+
this.children = this.children.filter(child => !isEmptyNode(child));
|
|
19788
19802
|
if (this.children.length !== 1) {
|
|
19789
19803
|
const child = this.children.find(child => !!child.animation);
|
|
19790
19804
|
component.error(child.animation, compiler_errors.invalid_animation_sole);
|
|
@@ -19797,6 +19811,9 @@ class EachBlock extends AbstractBlock {
|
|
|
19797
19811
|
: null;
|
|
19798
19812
|
}
|
|
19799
19813
|
}
|
|
19814
|
+
function isEmptyNode(node) {
|
|
19815
|
+
return node.type === 'Text' && node.data.trim() === '';
|
|
19816
|
+
}
|
|
19800
19817
|
|
|
19801
19818
|
function string_literal(data) {
|
|
19802
19819
|
return {
|
|
@@ -19979,7 +19996,7 @@ class Transition extends Node$1 {
|
|
|
19979
19996
|
super(component, parent, scope, info);
|
|
19980
19997
|
component.warn_if_undefined(info.name, info, scope);
|
|
19981
19998
|
this.name = info.name;
|
|
19982
|
-
component.add_reference(info.name.split('.')[0]);
|
|
19999
|
+
component.add_reference(this, info.name.split('.')[0]);
|
|
19983
20000
|
this.directive = info.intro && info.outro ? 'transition' : info.intro ? 'in' : 'out';
|
|
19984
20001
|
this.is_local = info.modifiers.includes('local');
|
|
19985
20002
|
if ((info.intro && parent.intro) || (info.outro && parent.outro)) {
|
|
@@ -19998,7 +20015,7 @@ class Animation extends Node$1 {
|
|
|
19998
20015
|
super(component, parent, scope, info);
|
|
19999
20016
|
component.warn_if_undefined(info.name, info, scope);
|
|
20000
20017
|
this.name = info.name;
|
|
20001
|
-
component.add_reference(info.name.split('.')[0]);
|
|
20018
|
+
component.add_reference(this, info.name.split('.')[0]);
|
|
20002
20019
|
if (parent.animation) {
|
|
20003
20020
|
component.error(this, compiler_errors.duplicate_animation);
|
|
20004
20021
|
return;
|
|
@@ -20941,7 +20958,7 @@ class InlineComponent extends Node$1 {
|
|
|
20941
20958
|
if (info.name !== 'svelte:component' && info.name !== 'svelte:self') {
|
|
20942
20959
|
const name = info.name.split('.')[0]; // accommodate namespaces
|
|
20943
20960
|
component.warn_if_undefined(name, info, scope);
|
|
20944
|
-
component.add_reference(name);
|
|
20961
|
+
component.add_reference(this, name);
|
|
20945
20962
|
}
|
|
20946
20963
|
this.name = info.name;
|
|
20947
20964
|
this.expression = this.name === 'svelte:component'
|
|
@@ -25947,7 +25964,7 @@ class Renderer {
|
|
|
25947
25964
|
const member = this.context_lookup.get(name);
|
|
25948
25965
|
// TODO is this correct?
|
|
25949
25966
|
if (this.component.var_lookup.get(name)) {
|
|
25950
|
-
this.component.add_reference(name);
|
|
25967
|
+
this.component.add_reference(node, name);
|
|
25951
25968
|
}
|
|
25952
25969
|
if (member !== undefined) {
|
|
25953
25970
|
const replacement = x `/*${member.name}*/ ${ctx}[${member.index}]`;
|
|
@@ -30611,26 +30628,32 @@ class Component {
|
|
|
30611
30628
|
this.stylesheet.reify();
|
|
30612
30629
|
this.stylesheet.warn_on_unused_selectors(this);
|
|
30613
30630
|
}
|
|
30614
|
-
add_var(variable, add_to_lookup = true) {
|
|
30631
|
+
add_var(node, variable, add_to_lookup = true) {
|
|
30615
30632
|
this.vars.push(variable);
|
|
30616
30633
|
if (add_to_lookup) {
|
|
30634
|
+
if (this.var_lookup.has(variable.name)) {
|
|
30635
|
+
const exists_var = this.var_lookup.get(variable.name);
|
|
30636
|
+
if (exists_var.module && exists_var.imported) {
|
|
30637
|
+
this.error(node, compiler_errors.illegal_variable_declaration);
|
|
30638
|
+
}
|
|
30639
|
+
}
|
|
30617
30640
|
this.var_lookup.set(variable.name, variable);
|
|
30618
30641
|
}
|
|
30619
30642
|
}
|
|
30620
|
-
add_reference(name) {
|
|
30643
|
+
add_reference(node, name) {
|
|
30621
30644
|
const variable = this.var_lookup.get(name);
|
|
30622
30645
|
if (variable) {
|
|
30623
30646
|
variable.referenced = true;
|
|
30624
30647
|
}
|
|
30625
30648
|
else if (is_reserved_keyword(name)) {
|
|
30626
|
-
this.add_var({
|
|
30649
|
+
this.add_var(node, {
|
|
30627
30650
|
name,
|
|
30628
30651
|
injected: true,
|
|
30629
30652
|
referenced: true
|
|
30630
30653
|
});
|
|
30631
30654
|
}
|
|
30632
30655
|
else if (name[0] === '$') {
|
|
30633
|
-
this.add_var({
|
|
30656
|
+
this.add_var(node, {
|
|
30634
30657
|
name,
|
|
30635
30658
|
injected: true,
|
|
30636
30659
|
referenced: true,
|
|
@@ -30646,7 +30669,7 @@ class Component {
|
|
|
30646
30669
|
}
|
|
30647
30670
|
else {
|
|
30648
30671
|
if (this.compile_options.varsReport === 'full') {
|
|
30649
|
-
this.add_var({ name, referenced: true }, false);
|
|
30672
|
+
this.add_var(node, { name, referenced: true }, false);
|
|
30650
30673
|
}
|
|
30651
30674
|
this.used_names.add(name);
|
|
30652
30675
|
}
|
|
@@ -30671,7 +30694,7 @@ class Component {
|
|
|
30671
30694
|
if (result) {
|
|
30672
30695
|
const { compile_options, name } = this;
|
|
30673
30696
|
const { format = 'esm' } = compile_options;
|
|
30674
|
-
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.46.
|
|
30697
|
+
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.46.3'}`;
|
|
30675
30698
|
const program = { type: 'Program', body: result.js };
|
|
30676
30699
|
walk(program, {
|
|
30677
30700
|
enter: (node, parent, key) => {
|
|
@@ -30945,11 +30968,13 @@ class Component {
|
|
|
30945
30968
|
return this.error(node, compiler_errors.illegal_declaration);
|
|
30946
30969
|
}
|
|
30947
30970
|
const writable = node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let');
|
|
30948
|
-
|
|
30971
|
+
const imported = node.type.startsWith('Import');
|
|
30972
|
+
this.add_var(node, {
|
|
30949
30973
|
name,
|
|
30950
30974
|
module: true,
|
|
30951
30975
|
hoistable: true,
|
|
30952
|
-
writable
|
|
30976
|
+
writable,
|
|
30977
|
+
imported
|
|
30953
30978
|
});
|
|
30954
30979
|
});
|
|
30955
30980
|
globals.forEach((node, name) => {
|
|
@@ -30957,7 +30982,7 @@ class Component {
|
|
|
30957
30982
|
return this.error(node, compiler_errors.illegal_subscription);
|
|
30958
30983
|
}
|
|
30959
30984
|
else {
|
|
30960
|
-
this.add_var({
|
|
30985
|
+
this.add_var(node, {
|
|
30961
30986
|
name,
|
|
30962
30987
|
global: true,
|
|
30963
30988
|
hoistable: true
|
|
@@ -31013,7 +31038,7 @@ class Component {
|
|
|
31013
31038
|
}
|
|
31014
31039
|
const writable = node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let');
|
|
31015
31040
|
const imported = node.type.startsWith('Import');
|
|
31016
|
-
this.add_var({
|
|
31041
|
+
this.add_var(node, {
|
|
31017
31042
|
name,
|
|
31018
31043
|
initialised: instance_scope.initialised_declarations.has(name),
|
|
31019
31044
|
writable,
|
|
@@ -31033,7 +31058,7 @@ class Component {
|
|
|
31033
31058
|
return;
|
|
31034
31059
|
const node = globals.get(name);
|
|
31035
31060
|
if (this.injected_reactive_declaration_vars.has(name)) {
|
|
31036
|
-
this.add_var({
|
|
31061
|
+
this.add_var(node, {
|
|
31037
31062
|
name,
|
|
31038
31063
|
injected: true,
|
|
31039
31064
|
writable: true,
|
|
@@ -31042,7 +31067,7 @@ class Component {
|
|
|
31042
31067
|
});
|
|
31043
31068
|
}
|
|
31044
31069
|
else if (is_reserved_keyword(name)) {
|
|
31045
|
-
this.add_var({
|
|
31070
|
+
this.add_var(node, {
|
|
31046
31071
|
name,
|
|
31047
31072
|
injected: true
|
|
31048
31073
|
});
|
|
@@ -31051,13 +31076,13 @@ class Component {
|
|
|
31051
31076
|
if (name === '$' || name[1] === '$') {
|
|
31052
31077
|
return this.error(node, compiler_errors.illegal_global(name));
|
|
31053
31078
|
}
|
|
31054
|
-
this.add_var({
|
|
31079
|
+
this.add_var(node, {
|
|
31055
31080
|
name,
|
|
31056
31081
|
injected: true,
|
|
31057
31082
|
mutated: true,
|
|
31058
31083
|
writable: true
|
|
31059
31084
|
});
|
|
31060
|
-
this.add_reference(name.slice(1));
|
|
31085
|
+
this.add_reference(node, name.slice(1));
|
|
31061
31086
|
const variable = this.var_lookup.get(name.slice(1));
|
|
31062
31087
|
if (variable) {
|
|
31063
31088
|
variable.subscribable = true;
|
|
@@ -31065,7 +31090,7 @@ class Component {
|
|
|
31065
31090
|
}
|
|
31066
31091
|
}
|
|
31067
31092
|
else {
|
|
31068
|
-
this.add_var({
|
|
31093
|
+
this.add_var(node, {
|
|
31069
31094
|
name,
|
|
31070
31095
|
global: true,
|
|
31071
31096
|
hoistable: true
|
|
@@ -32162,7 +32187,7 @@ async function preprocess(source, preprocessor, options) {
|
|
|
32162
32187
|
return result.to_processed();
|
|
32163
32188
|
}
|
|
32164
32189
|
|
|
32165
|
-
const VERSION = '3.46.
|
|
32190
|
+
const VERSION = '3.46.3';
|
|
32166
32191
|
|
|
32167
32192
|
export { VERSION, compile, parse$3 as parse, preprocess, walk };
|
|
32168
32193
|
//# sourceMappingURL=compiler.mjs.map
|