Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reinstate comments #3870

Merged
merged 4 commits into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@
},
"homepage": "https://github.com/sveltejs/svelte#README",
"devDependencies": {
"@rollup/plugin-replace": "^2.2.1",
"@types/mocha": "^5.2.7",
"@types/node": "^8.10.53",
"@typescript-eslint/eslint-plugin": "^1.13.0",
"@typescript-eslint/parser": "^2.1.0",
"@rollup/plugin-replace": "^2.2.1",
"acorn": "^7.1.0",
"agadoo": "^1.1.0",
"c8": "^5.0.1",
"code-red": "0.0.18",
"code-red": "0.0.19",
"codecov": "^3.5.0",
"css-tree": "1.0.0-alpha22",
"eslint": "^6.3.0",
Expand Down
3 changes: 1 addition & 2 deletions src/compiler/compile/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ export default class Component {
const { compile_options, name } = this;
const { format = 'esm' } = compile_options;

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

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

Expand Down
8 changes: 6 additions & 2 deletions src/compiler/compile/create_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function edit_source(source, sveltePath) {
function esm(
program: any,
name: Identifier,
_banner: string,
banner: string,
sveltePath: string,
internal_path: string,
helpers: Array<{ name: string; alias: Identifier }>,
Expand Down Expand Up @@ -98,6 +98,8 @@ function esm(
};

program.body = b`
/* ${banner} */

${import_declaration}
${internal_globals}
${imports}
Expand All @@ -112,7 +114,7 @@ function esm(
function cjs(
program: any,
name: Identifier,
_banner: string,
banner: string,
sveltePath: string,
internal_path: string,
helpers: Array<{ name: string; alias: Identifier }>,
Expand Down Expand Up @@ -188,6 +190,8 @@ function cjs(
const exports = module_exports.map(x => b`exports.${{ type: 'Identifier', name: x.as }} = ${{ type: 'Identifier', name: x.name }};`);

program.body = b`
/* ${banner} */

"use strict";
${internal_requires}
${internal_globals}
Expand Down
16 changes: 8 additions & 8 deletions src/compiler/compile/render_dom/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,17 +423,17 @@ export default class Block {
const key = this.key && this.get_unique_name('key');

const args: any[] = [x`#ctx`];

if (key) args.unshift(key);

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

return b`
function ${this.name}(${args}) {
${this.get_contents(key)}
}
`;
return this.comment
? b`
// ${this.comment}
${fn}`
: fn;
}

render_listeners(chunk: string = '') {
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/action-custom-event-handler/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
detach,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/action/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
attr,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/bind-online/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
add_render_callback,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/bind-open/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
detach,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/bind-width-height/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
add_render_callback,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/bindings-readonly-order/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
attr,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/capture-inject-dev-only/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/collapses-text-around-comments/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/component-static-array/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
create_component,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/component-static-immutable/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
create_component,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/component-static-immutable2/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
create_component,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/component-static-var/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
create_component,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/component-static/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
create_component,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
component_subscribe,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/computed-collapsed-if/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal";

function instance($$self, $$props, $$invalidate) {
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/css-media-query/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/css-shadow-dom-keyframes/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteElement,
detach,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/data-attribute/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
attr,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/debug-empty/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponentDev,
add_location,
Expand Down
2 changes: 2 additions & 0 deletions test/js/samples/debug-foo-bar-baz-things/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponentDev,
add_location,
Expand All @@ -23,6 +24,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}

// (8:0) {#each things as thing}
function create_each_block(ctx) {
let span;
let t0_value = ctx.thing.name + "";
Expand Down
2 changes: 2 additions & 0 deletions test/js/samples/debug-foo/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponentDev,
add_location,
Expand All @@ -23,6 +24,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}

// (6:0) {#each things as thing}
function create_each_block(ctx) {
let span;
let t0_value = ctx.thing.name + "";
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/debug-hoisted/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponentDev,
dispatch_dev,
Expand Down
2 changes: 2 additions & 0 deletions test/js/samples/debug-no-dependencies/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponentDev,
destroy_each,
Expand All @@ -21,6 +22,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}

// (4:0) {#each things as thing, index}
function create_each_block(ctx) {
let t0;
let t1_value = ctx.thing + "";
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/debug-ssr-foo/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { create_ssr_component, debug, each, escape } from "svelte/internal";

const Component = create_ssr_component(($$result, $$props, $$bindings, $$slots) => {
Expand Down
2 changes: 2 additions & 0 deletions test/js/samples/deconflict-builtins/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand All @@ -19,6 +20,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}

// (5:0) {#each createElement as node}
function create_each_block(ctx) {
let span;
let t_value = ctx.node + "";
Expand Down
2 changes: 2 additions & 0 deletions test/js/samples/deconflict-globals/expected.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal";

import { onMount } from "svelte";

function instance($$self, $$props, $$invalidate) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponentDev,
add_location,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/dont-invalidate-this/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
detach,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/dynamic-import/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
create_component,
Expand Down
2 changes: 2 additions & 0 deletions test/js/samples/each-block-array-literal/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand All @@ -19,6 +20,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}

// (9:0) {#each [a, b, c, d, e] as num}
function create_each_block(ctx) {
let span;
let t_value = ctx.num + "";
Expand Down
10 changes: 3 additions & 7 deletions test/js/samples/each-block-changed-check/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
HtmlTag,
SvelteComponent,
Expand All @@ -22,6 +23,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}

// (8:0) {#each comments as comment, i}
function create_each_block(ctx) {
let div;
let strong;
Expand Down Expand Up @@ -163,13 +165,7 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();

init(this, options, instance, create_fragment, safe_not_equal, {
comments: 0,
elapsed: 0,
time: 0,
foo: 0
});
init(this, options, instance, create_fragment, safe_not_equal, { comments: 0, elapsed: 0, time: 0, foo: 0 });
}
}

Expand Down
2 changes: 2 additions & 0 deletions test/js/samples/each-block-keyed-animated/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand All @@ -22,6 +23,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}

// (19:0) {#each things as thing (thing.id)}
function create_each_block(key_1, ctx) {
let div;
let t_value = ctx.thing.name + "";
Expand Down
2 changes: 2 additions & 0 deletions test/js/samples/each-block-keyed/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand All @@ -20,6 +21,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}

// (5:0) {#each things as thing (thing.id)}
function create_each_block(key_1, ctx) {
let div;
let t_value = ctx.thing.name + "";
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/empty-dom/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal";

function instance($$self) {
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/event-handler-dynamic/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/event-handler-no-passive/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
attr,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/event-modifiers/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/head-no-whitespace/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/hoisted-const/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
detach,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/hoisted-let/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
detach,
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/if-block-complex/expected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
attr,
Expand Down
Loading