svelte 3.43.1 → 3.44.2
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 +20 -0
- package/README.md +1 -1
- package/compiler.js +69 -47
- package/compiler.js.map +1 -1
- package/compiler.mjs +69 -47
- package/compiler.mjs.map +1 -1
- package/internal/index.js +1 -1
- package/internal/index.mjs +1 -1
- package/package.json +17 -4
- package/types/compiler/compile/utils/check_enable_sourcemap.d.ts +2 -0
- package/types/compiler/interfaces.d.ts +5 -0
- package/types/compiler/preprocess/types.d.ts +3 -3
- package/types/compiler/utils/patterns.d.ts +2 -0
- package/types/runtime/transition/index.d.ts +4 -2
package/compiler.mjs
CHANGED
|
@@ -6492,7 +6492,7 @@ const handlers = {
|
|
|
6492
6492
|
}),
|
|
6493
6493
|
|
|
6494
6494
|
EmptyStatement(node, state) {
|
|
6495
|
-
return [];
|
|
6495
|
+
return [c(';')];
|
|
6496
6496
|
},
|
|
6497
6497
|
|
|
6498
6498
|
ParenthesizedExpression(node, state) {
|
|
@@ -6598,10 +6598,11 @@ const handlers = {
|
|
|
6598
6598
|
|
|
6599
6599
|
ReturnStatement(node, state) {
|
|
6600
6600
|
if (node.argument) {
|
|
6601
|
+
const contains_comment = node.argument.leadingComments && node.argument.leadingComments.some((/** @type import('../utils/comments.js').CommentWithLocation */ comment) => comment.has_trailing_newline);
|
|
6601
6602
|
return [
|
|
6602
|
-
c('return '),
|
|
6603
|
+
c(contains_comment ? 'return (' : 'return '),
|
|
6603
6604
|
...handle(node.argument, state),
|
|
6604
|
-
c(';')
|
|
6605
|
+
c(contains_comment ? ');' : ';')
|
|
6605
6606
|
];
|
|
6606
6607
|
} else {
|
|
6607
6608
|
return [c('return;')];
|
|
@@ -7955,7 +7956,7 @@ const inject = (raw, node, values, comments) => {
|
|
|
7955
7956
|
|
|
7956
7957
|
const { enter, leave } = get_comment_handlers(comments, raw);
|
|
7957
7958
|
|
|
7958
|
-
walk(node, {
|
|
7959
|
+
return walk(node, {
|
|
7959
7960
|
enter,
|
|
7960
7961
|
|
|
7961
7962
|
/** @param {any} node */
|
|
@@ -8057,7 +8058,6 @@ const inject = (raw, node, values, comments) => {
|
|
|
8057
8058
|
node.update = node.update === EMPTY ? null : node.update;
|
|
8058
8059
|
}
|
|
8059
8060
|
|
|
8060
|
-
// @ts-ignore
|
|
8061
8061
|
leave(node);
|
|
8062
8062
|
}
|
|
8063
8063
|
});
|
|
@@ -8076,11 +8076,11 @@ function b(strings, ...values) {
|
|
|
8076
8076
|
const comments = [];
|
|
8077
8077
|
|
|
8078
8078
|
try {
|
|
8079
|
-
|
|
8079
|
+
let ast = /** @type {any} */ (
|
|
8080
8080
|
parse(str, acorn_opts(comments, str))
|
|
8081
8081
|
);
|
|
8082
8082
|
|
|
8083
|
-
inject(str, ast, values, comments);
|
|
8083
|
+
ast = inject(str, ast, values, comments);
|
|
8084
8084
|
|
|
8085
8085
|
return ast.body;
|
|
8086
8086
|
} catch (err) {
|
|
@@ -8101,7 +8101,7 @@ function x(strings, ...values) {
|
|
|
8101
8101
|
const comments = [];
|
|
8102
8102
|
|
|
8103
8103
|
try {
|
|
8104
|
-
|
|
8104
|
+
let expression =
|
|
8105
8105
|
/** @type {Expression & { start: Number, end: number }} */ (
|
|
8106
8106
|
parseExpressionAt(str, 0, acorn_opts(comments, str))
|
|
8107
8107
|
);
|
|
@@ -8110,7 +8110,9 @@ function x(strings, ...values) {
|
|
|
8110
8110
|
throw new Error(`Unexpected token '${match[0]}'`);
|
|
8111
8111
|
}
|
|
8112
8112
|
|
|
8113
|
-
|
|
8113
|
+
expression = /** @type {Expression & { start: Number, end: number }} */ (
|
|
8114
|
+
inject(str, expression, values, comments)
|
|
8115
|
+
);
|
|
8114
8116
|
|
|
8115
8117
|
return expression;
|
|
8116
8118
|
} catch (err) {
|
|
@@ -8131,11 +8133,11 @@ function p(strings, ...values) {
|
|
|
8131
8133
|
const comments = [];
|
|
8132
8134
|
|
|
8133
8135
|
try {
|
|
8134
|
-
|
|
8136
|
+
let expression = /** @type {any} */ (
|
|
8135
8137
|
parseExpressionAt(str, 0, acorn_opts(comments, str))
|
|
8136
8138
|
);
|
|
8137
8139
|
|
|
8138
|
-
inject(str, expression, values, comments);
|
|
8140
|
+
expression = inject(str, expression, values, comments);
|
|
8139
8141
|
|
|
8140
8142
|
return expression.properties[0];
|
|
8141
8143
|
} catch (err) {
|
|
@@ -8204,6 +8206,8 @@ const parse_expression_at = (source, index) => parseExpressionAt$1(source, index
|
|
|
8204
8206
|
});
|
|
8205
8207
|
|
|
8206
8208
|
const whitespace = /[ \t\r\n]/;
|
|
8209
|
+
const start_whitespace = /^[ \t\r\n]*/;
|
|
8210
|
+
const end_whitespace = /[ \t\r\n]*$/;
|
|
8207
8211
|
const dimensions = /^(?:offset|client)(?:Width|Height)$/;
|
|
8208
8212
|
|
|
8209
8213
|
function list(items, conjunction = 'or') {
|
|
@@ -16390,6 +16394,7 @@ const globals = new Set([
|
|
|
16390
16394
|
'undefined',
|
|
16391
16395
|
'URIError',
|
|
16392
16396
|
'URL',
|
|
16397
|
+
'URLSearchParams',
|
|
16393
16398
|
'window'
|
|
16394
16399
|
]);
|
|
16395
16400
|
const reserved = new Set([
|
|
@@ -17218,16 +17223,10 @@ function read_context(parser) {
|
|
|
17218
17223
|
}
|
|
17219
17224
|
|
|
17220
17225
|
function trim_start(str) {
|
|
17221
|
-
|
|
17222
|
-
while (whitespace.test(str[i]))
|
|
17223
|
-
i += 1;
|
|
17224
|
-
return str.slice(i);
|
|
17226
|
+
return str.replace(start_whitespace, '');
|
|
17225
17227
|
}
|
|
17226
17228
|
function trim_end(str) {
|
|
17227
|
-
|
|
17228
|
-
while (whitespace.test(str[i - 1]))
|
|
17229
|
-
i -= 1;
|
|
17230
|
-
return str.slice(0, i);
|
|
17229
|
+
return str.replace(end_whitespace, '');
|
|
17231
17230
|
}
|
|
17232
17231
|
|
|
17233
17232
|
function to_string(node) {
|
|
@@ -24924,6 +24923,12 @@ function parse_attached_sourcemap(processed, tag_name) {
|
|
|
24924
24923
|
});
|
|
24925
24924
|
}
|
|
24926
24925
|
|
|
24926
|
+
function check_enable_sourcemap(enable_sourcemap, namespace) {
|
|
24927
|
+
return typeof enable_sourcemap === 'boolean'
|
|
24928
|
+
? enable_sourcemap
|
|
24929
|
+
: enable_sourcemap[namespace];
|
|
24930
|
+
}
|
|
24931
|
+
|
|
24927
24932
|
function dom(component, options) {
|
|
24928
24933
|
const { name } = component;
|
|
24929
24934
|
const renderer = new Renderer(component, options);
|
|
@@ -24938,8 +24943,14 @@ function dom(component, options) {
|
|
|
24938
24943
|
body.push(b `const ${renderer.file_var} = ${file};`);
|
|
24939
24944
|
}
|
|
24940
24945
|
const css = component.stylesheet.render(options.filename, !options.customElement);
|
|
24941
|
-
|
|
24942
|
-
|
|
24946
|
+
const css_sourcemap_enabled = check_enable_sourcemap(options.enableSourcemap, 'css');
|
|
24947
|
+
if (css_sourcemap_enabled) {
|
|
24948
|
+
css.map = apply_preprocessor_sourcemap(options.filename, css.map, options.sourcemap);
|
|
24949
|
+
}
|
|
24950
|
+
else {
|
|
24951
|
+
css.map = null;
|
|
24952
|
+
}
|
|
24953
|
+
const styles = css_sourcemap_enabled && component.stylesheet.has_styles && options.dev
|
|
24943
24954
|
? `${css.code}\n/*# sourceMappingURL=${css.map.toUrl()} */`
|
|
24944
24955
|
: css.code;
|
|
24945
24956
|
const add_css = component.get_unique_name('add_css');
|
|
@@ -25345,7 +25356,7 @@ function dom(component, options) {
|
|
|
25345
25356
|
constructor(options) {
|
|
25346
25357
|
super();
|
|
25347
25358
|
|
|
25348
|
-
${css.code && b `this.shadowRoot.innerHTML = \`<style>${css.code.replace(/\\/g, '\\\\')}${options.dev ? `\n/*# sourceMappingURL=${css.map.toUrl()} */` : ''}</style>\`;`}
|
|
25359
|
+
${css.code && b `this.shadowRoot.innerHTML = \`<style>${css.code.replace(/\\/g, '\\\\')}${css_sourcemap_enabled && options.dev ? `\n/*# sourceMappingURL=${css.map.toUrl()} */` : ''}</style>\`;`}
|
|
25349
25360
|
|
|
25350
25361
|
@init(this, { target: this.shadowRoot, props: ${init_props}, customElement: true }, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, null, ${dirty});
|
|
25351
25362
|
|
|
@@ -27747,11 +27758,12 @@ function ssr(component, options) {
|
|
|
27747
27758
|
css.code && b `$$result.css.add(#css);`,
|
|
27748
27759
|
main
|
|
27749
27760
|
].filter(Boolean);
|
|
27761
|
+
const css_sourcemap_enabled = check_enable_sourcemap(options.enableSourcemap, 'css');
|
|
27750
27762
|
const js = b `
|
|
27751
27763
|
${css.code ? b `
|
|
27752
27764
|
const #css = {
|
|
27753
27765
|
code: "${css.code}",
|
|
27754
|
-
map: ${css.map ? string_literal(css.map.toString()) : 'null'}
|
|
27766
|
+
map: ${css_sourcemap_enabled && css.map ? string_literal(css.map.toString()) : 'null'}
|
|
27755
27767
|
};` : null}
|
|
27756
27768
|
|
|
27757
27769
|
${component.extract_javascript(component.ast.module)}
|
|
@@ -27836,12 +27848,15 @@ function esm(program, name, banner, sveltePath, internal_path, helpers, globals,
|
|
|
27836
27848
|
};
|
|
27837
27849
|
const internal_globals = get_internal_globals(globals, helpers);
|
|
27838
27850
|
// edit user imports
|
|
27839
|
-
|
|
27840
|
-
|
|
27841
|
-
|
|
27842
|
-
|
|
27843
|
-
|
|
27844
|
-
|
|
27851
|
+
function rewrite_import(node) {
|
|
27852
|
+
const value = edit_source(node.source.value, sveltePath);
|
|
27853
|
+
if (node.source.value !== value) {
|
|
27854
|
+
node.source.value = value;
|
|
27855
|
+
node.source.raw = null;
|
|
27856
|
+
}
|
|
27857
|
+
}
|
|
27858
|
+
imports.forEach(rewrite_import);
|
|
27859
|
+
exports_from.forEach(rewrite_import);
|
|
27845
27860
|
const exports = module_exports.length > 0 && {
|
|
27846
27861
|
type: 'ExportNamedDeclaration',
|
|
27847
27862
|
specifiers: module_exports.map(x => ({
|
|
@@ -30120,7 +30135,7 @@ class Component {
|
|
|
30120
30135
|
if (result) {
|
|
30121
30136
|
const { compile_options, name } = this;
|
|
30122
30137
|
const { format = 'esm' } = compile_options;
|
|
30123
|
-
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.
|
|
30138
|
+
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.44.2'}`;
|
|
30124
30139
|
const program = { type: 'Program', body: result.js };
|
|
30125
30140
|
walk(program, {
|
|
30126
30141
|
enter: (node, parent, key) => {
|
|
@@ -30184,17 +30199,24 @@ class Component {
|
|
|
30184
30199
|
css = compile_options.customElement
|
|
30185
30200
|
? { code: null, map: null }
|
|
30186
30201
|
: result.css;
|
|
30187
|
-
const
|
|
30188
|
-
|
|
30189
|
-
|
|
30190
|
-
|
|
30191
|
-
|
|
30192
|
-
|
|
30193
|
-
|
|
30194
|
-
|
|
30195
|
-
|
|
30196
|
-
|
|
30197
|
-
|
|
30202
|
+
const js_sourcemap_enabled = check_enable_sourcemap(compile_options.enableSourcemap, 'js');
|
|
30203
|
+
if (!js_sourcemap_enabled) {
|
|
30204
|
+
js = print(program);
|
|
30205
|
+
js.map = null;
|
|
30206
|
+
}
|
|
30207
|
+
else {
|
|
30208
|
+
const sourcemap_source_filename = get_sourcemap_source_filename(compile_options);
|
|
30209
|
+
js = print(program, {
|
|
30210
|
+
sourceMapSource: sourcemap_source_filename
|
|
30211
|
+
});
|
|
30212
|
+
js.map.sources = [
|
|
30213
|
+
sourcemap_source_filename
|
|
30214
|
+
];
|
|
30215
|
+
js.map.sourcesContent = [
|
|
30216
|
+
this.source
|
|
30217
|
+
];
|
|
30218
|
+
js.map = apply_preprocessor_sourcemap(sourcemap_source_filename, js.map, compile_options.sourcemap);
|
|
30219
|
+
}
|
|
30198
30220
|
}
|
|
30199
30221
|
return {
|
|
30200
30222
|
js,
|
|
@@ -31242,6 +31264,7 @@ const valid_options = [
|
|
|
31242
31264
|
'name',
|
|
31243
31265
|
'filename',
|
|
31244
31266
|
'sourcemap',
|
|
31267
|
+
'enableSourcemap',
|
|
31245
31268
|
'generate',
|
|
31246
31269
|
'errorMode',
|
|
31247
31270
|
'varsReport',
|
|
@@ -31305,7 +31328,7 @@ function validate_options(options, warnings) {
|
|
|
31305
31328
|
}
|
|
31306
31329
|
}
|
|
31307
31330
|
function compile(source, options = {}) {
|
|
31308
|
-
options = Object.assign({ generate: 'dom', dev: false }, options);
|
|
31331
|
+
options = Object.assign({ generate: 'dom', dev: false, enableSourcemap: true }, options);
|
|
31309
31332
|
const stats = new Stats();
|
|
31310
31333
|
const warnings = [];
|
|
31311
31334
|
validate_options(options, warnings);
|
|
@@ -31559,10 +31582,10 @@ async function process_tag(tag_name, preprocessor, source) {
|
|
|
31559
31582
|
const { string, map } = await replace_in_code(tag_regex, process_single_tag, source);
|
|
31560
31583
|
return { string, map, dependencies };
|
|
31561
31584
|
}
|
|
31562
|
-
async function process_markup(
|
|
31585
|
+
async function process_markup(process, source) {
|
|
31563
31586
|
const processed = await process({
|
|
31564
31587
|
content: source.source,
|
|
31565
|
-
filename
|
|
31588
|
+
filename: source.filename
|
|
31566
31589
|
});
|
|
31567
31590
|
if (processed) {
|
|
31568
31591
|
return {
|
|
@@ -31581,7 +31604,6 @@ async function process_markup(filename, process, source) {
|
|
|
31581
31604
|
}
|
|
31582
31605
|
}
|
|
31583
31606
|
async function preprocess(source, preprocessor, options) {
|
|
31584
|
-
// @ts-ignore todo: doublecheck
|
|
31585
31607
|
const filename = (options && options.filename) || preprocessor.filename; // legacy
|
|
31586
31608
|
const preprocessors = preprocessor ? (Array.isArray(preprocessor) ? preprocessor : [preprocessor]) : [];
|
|
31587
31609
|
const markup = preprocessors.map(p => p.markup).filter(Boolean);
|
|
@@ -31591,7 +31613,7 @@ async function preprocess(source, preprocessor, options) {
|
|
|
31591
31613
|
// TODO keep track: what preprocessor generated what sourcemap?
|
|
31592
31614
|
// to make debugging easier = detect low-resolution sourcemaps in fn combine_mappings
|
|
31593
31615
|
for (const process of markup) {
|
|
31594
|
-
result.update_source(await process_markup(
|
|
31616
|
+
result.update_source(await process_markup(process, result));
|
|
31595
31617
|
}
|
|
31596
31618
|
for (const process of script) {
|
|
31597
31619
|
result.update_source(await process_tag('script', process, result));
|
|
@@ -31602,7 +31624,7 @@ async function preprocess(source, preprocessor, options) {
|
|
|
31602
31624
|
return result.to_processed();
|
|
31603
31625
|
}
|
|
31604
31626
|
|
|
31605
|
-
const VERSION = '3.
|
|
31627
|
+
const VERSION = '3.44.2';
|
|
31606
31628
|
|
|
31607
31629
|
export { VERSION, compile, parse$3 as parse, preprocess, walk };
|
|
31608
31630
|
//# sourceMappingURL=compiler.mjs.map
|