Skip to content

Commit 4ffa6fc

Browse files
authored
Merge pull request #3870 from sveltejs/gh-3855
reinstate comments
2 parents de80ae7 + 9851980 commit 4ffa6fc

File tree

82 files changed

+116
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+116
-29
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@
5656
},
5757
"homepage": "https://github.com/sveltejs/svelte#README",
5858
"devDependencies": {
59+
"@rollup/plugin-replace": "^2.2.1",
5960
"@types/mocha": "^5.2.7",
6061
"@types/node": "^8.10.53",
6162
"@typescript-eslint/eslint-plugin": "^1.13.0",
6263
"@typescript-eslint/parser": "^2.1.0",
63-
"@rollup/plugin-replace": "^2.2.1",
6464
"acorn": "^7.1.0",
6565
"agadoo": "^1.1.0",
6666
"c8": "^5.0.1",
67-
"code-red": "0.0.18",
67+
"code-red": "0.0.19",
6868
"codecov": "^3.5.0",
6969
"css-tree": "1.0.0-alpha22",
7070
"eslint": "^6.3.0",

src/compiler/compile/Component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ export default class Component {
240240
const { compile_options, name } = this;
241241
const { format = 'esm' } = compile_options;
242242

243-
// TODO reinstate banner (along with fragment marker comments)
244-
const banner = `/* ${this.file ? `${this.file} ` : ``}generated by Svelte v${'__VERSION__'} */`;
243+
const banner = `${this.file ? `${this.file} ` : ``}generated by Svelte v${'__VERSION__'}`;
245244

246245
const program: any = { type: 'Program', body: result };
247246

src/compiler/compile/create_module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function edit_source(source, sveltePath) {
4444
function esm(
4545
program: any,
4646
name: Identifier,
47-
_banner: string,
47+
banner: string,
4848
sveltePath: string,
4949
internal_path: string,
5050
helpers: Array<{ name: string; alias: Identifier }>,
@@ -98,6 +98,8 @@ function esm(
9898
};
9999

100100
program.body = b`
101+
/* ${banner} */
102+
101103
${import_declaration}
102104
${internal_globals}
103105
${imports}
@@ -112,7 +114,7 @@ function esm(
112114
function cjs(
113115
program: any,
114116
name: Identifier,
115-
_banner: string,
117+
banner: string,
116118
sveltePath: string,
117119
internal_path: string,
118120
helpers: Array<{ name: string; alias: Identifier }>,
@@ -188,6 +190,8 @@ function cjs(
188190
const exports = module_exports.map(x => b`exports.${{ type: 'Identifier', name: x.as }} = ${{ type: 'Identifier', name: x.name }};`);
189191

190192
program.body = b`
193+
/* ${banner} */
194+
191195
"use strict";
192196
${internal_requires}
193197
${internal_globals}

src/compiler/compile/render_dom/Block.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,17 +423,17 @@ export default class Block {
423423
const key = this.key && this.get_unique_name('key');
424424

425425
const args: any[] = [x`#ctx`];
426-
427426
if (key) args.unshift(key);
428427

429-
// TODO include this.comment
430-
// ${this.comment && `// ${escape(this.comment, { only_escape_at_symbol: true })}`}
428+
const fn = b`function ${this.name}(${args}) {
429+
${this.get_contents(key)}
430+
}`;
431431

432-
return b`
433-
function ${this.name}(${args}) {
434-
${this.get_contents(key)}
435-
}
436-
`;
432+
return this.comment
433+
? b`
434+
// ${this.comment}
435+
${fn}`
436+
: fn;
437437
}
438438

439439
render_listeners(chunk: string = '') {

test/js/samples/action-custom-event-handler/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
detach,

test/js/samples/action/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
attr,

test/js/samples/bind-online/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
add_render_callback,

test/js/samples/bind-open/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
detach,

test/js/samples/bind-width-height/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
add_render_callback,

test/js/samples/bindings-readonly-order/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
attr,

test/js/samples/capture-inject-dev-only/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,

test/js/samples/collapses-text-around-comments/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,

test/js/samples/component-static-array/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
create_component,

test/js/samples/component-static-immutable/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
create_component,

test/js/samples/component-static-immutable2/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
create_component,

test/js/samples/component-static-var/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
create_component,

test/js/samples/component-static/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
create_component,

test/js/samples/component-store-access-invalidate/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,

test/js/samples/component-store-file-invalidate/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
component_subscribe,

test/js/samples/component-store-reassign-invalidate/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,

test/js/samples/computed-collapsed-if/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
23

34
function instance($$self, $$props, $$invalidate) {

test/js/samples/css-media-query/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,

test/js/samples/css-shadow-dom-keyframes/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteElement,
34
detach,

test/js/samples/data-attribute/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
attr,

test/js/samples/debug-empty/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponentDev,
34
add_location,

test/js/samples/debug-foo-bar-baz-things/expected.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponentDev,
34
add_location,
@@ -23,6 +24,7 @@ function get_each_context(ctx, list, i) {
2324
return child_ctx;
2425
}
2526

27+
// (8:0) {#each things as thing}
2628
function create_each_block(ctx) {
2729
let span;
2830
let t0_value = ctx.thing.name + "";

test/js/samples/debug-foo/expected.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponentDev,
34
add_location,
@@ -23,6 +24,7 @@ function get_each_context(ctx, list, i) {
2324
return child_ctx;
2425
}
2526

27+
// (6:0) {#each things as thing}
2628
function create_each_block(ctx) {
2729
let span;
2830
let t0_value = ctx.thing.name + "";

test/js/samples/debug-hoisted/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponentDev,
34
dispatch_dev,

test/js/samples/debug-no-dependencies/expected.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponentDev,
34
destroy_each,
@@ -21,6 +22,7 @@ function get_each_context(ctx, list, i) {
2122
return child_ctx;
2223
}
2324

25+
// (4:0) {#each things as thing, index}
2426
function create_each_block(ctx) {
2527
let t0;
2628
let t1_value = ctx.thing + "";

test/js/samples/debug-ssr-foo/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import { create_ssr_component, debug, each, escape } from "svelte/internal";
23

34
const Component = create_ssr_component(($$result, $$props, $$bindings, $$slots) => {

test/js/samples/deconflict-builtins/expected.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,
@@ -19,6 +20,7 @@ function get_each_context(ctx, list, i) {
1920
return child_ctx;
2021
}
2122

23+
// (5:0) {#each createElement as node}
2224
function create_each_block(ctx) {
2325
let span;
2426
let t_value = ctx.node + "";

test/js/samples/deconflict-globals/expected.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
/* generated by Svelte vX.Y.Z */
12
import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
3+
24
import { onMount } from "svelte";
35

46
function instance($$self, $$props, $$invalidate) {

test/js/samples/dev-warning-missing-data-computed/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponentDev,
34
add_location,

test/js/samples/dont-invalidate-this/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
detach,

test/js/samples/dynamic-import/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
create_component,

test/js/samples/each-block-array-literal/expected.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,
@@ -19,6 +20,7 @@ function get_each_context(ctx, list, i) {
1920
return child_ctx;
2021
}
2122

23+
// (9:0) {#each [a, b, c, d, e] as num}
2224
function create_each_block(ctx) {
2325
let span;
2426
let t_value = ctx.num + "";

test/js/samples/each-block-changed-check/expected.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
HtmlTag,
34
SvelteComponent,
@@ -22,6 +23,7 @@ function get_each_context(ctx, list, i) {
2223
return child_ctx;
2324
}
2425

26+
// (8:0) {#each comments as comment, i}
2527
function create_each_block(ctx) {
2628
let div;
2729
let strong;
@@ -163,13 +165,7 @@ function instance($$self, $$props, $$invalidate) {
163165
class Component extends SvelteComponent {
164166
constructor(options) {
165167
super();
166-
167-
init(this, options, instance, create_fragment, safe_not_equal, {
168-
comments: 0,
169-
elapsed: 0,
170-
time: 0,
171-
foo: 0
172-
});
168+
init(this, options, instance, create_fragment, safe_not_equal, { comments: 0, elapsed: 0, time: 0, foo: 0 });
173169
}
174170
}
175171

test/js/samples/each-block-keyed-animated/expected.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,
@@ -22,6 +23,7 @@ function get_each_context(ctx, list, i) {
2223
return child_ctx;
2324
}
2425

26+
// (19:0) {#each things as thing (thing.id)}
2527
function create_each_block(key_1, ctx) {
2628
let div;
2729
let t_value = ctx.thing.name + "";

test/js/samples/each-block-keyed/expected.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,
@@ -20,6 +21,7 @@ function get_each_context(ctx, list, i) {
2021
return child_ctx;
2122
}
2223

24+
// (5:0) {#each things as thing (thing.id)}
2325
function create_each_block(key_1, ctx) {
2426
let div;
2527
let t_value = ctx.thing.name + "";

test/js/samples/empty-dom/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
23

34
function instance($$self) {

test/js/samples/event-handler-dynamic/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,

test/js/samples/event-handler-no-passive/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
attr,

test/js/samples/event-modifiers/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,

test/js/samples/head-no-whitespace/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
append,

test/js/samples/hoisted-const/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
detach,

test/js/samples/hoisted-let/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
detach,

test/js/samples/if-block-complex/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* generated by Svelte vX.Y.Z */
12
import {
23
SvelteComponent,
34
attr,

0 commit comments

Comments
 (0)