pull/3539/head
Richard Harris 6 years ago
parent 2ce451f29d
commit 42e1c8f191

@ -253,41 +253,11 @@ 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__'} */`;
// result = result
// .replace(/__svelte:self__/g, this.name)
// .replace(
// compile_options.generate === 'ssr'
// ? /(@+|#+)(\w*(?:-\w*)?)/g
// : /(@+)(\w*(?:-\w*)?)/g,
// (_match: string, sigil: string, name: string) => {
// if (sigil === '@') {
// if (name[0] === '_') {
// return this.global(name.slice(1));
// }
// if (!internal_exports.has(name)) {
// throw new Error(
// `compiler error: this shouldn't happen! generated code is trying to use inexistent internal '${name}'`
// );
// }
// if (compile_options.dev) {
// if (internal_exports.has(`${name}_dev`)) name = `${name}_dev`;
// else if (internal_exports.has(`${name}Dev`))
// name = `${name}Dev`;
// }
// return this.helper(name);
// }
// return sigil.slice(1) + name;
// }
// );
const program: any = { type: 'Program', body: result };
walk(program, {

@ -23,6 +23,11 @@ export default function create_module(
) {
const internal_path = `${sveltePath}/internal`;
helpers.sort((a, b) => {
if (a.name < b.name) return -1;
return 1;
});
if (format === 'esm') {
return esm(program, name, banner, sveltePath, internal_path, helpers, globals, imports, module_exports);
}

@ -352,6 +352,14 @@ export default class Block {
}`;
}
if (!this.renderer.component.compile_options.dev) {
// allow shorthand names
for (const name in properties) {
const property = properties[name];
if (property) property.id = null;
}
}
const return_value: any = x`{
key: ${properties.key},
first: ${properties.first},

@ -167,7 +167,7 @@ export default class WindowWrapper extends Wrapper {
component.partly_hoisted.push(b`
function ${id}() {
${name} = @_navigator.onLine; $$invalidate('${name}', ${name});
$$invalidate('${name}', ${name} = @_navigator.onLine);
}
`);

@ -3,7 +3,7 @@ import * as fs from "fs";
import * as path from "path";
import { loadConfig, svelte } from "../helpers.js";
describe.skip("js", () => {
describe.only("js", () => {
fs.readdirSync("test/js/samples").forEach(dir => {
if (dir[0] === ".") return;

@ -10,8 +10,7 @@ import {
} from "svelte/internal";
function create_fragment(ctx) {
var dispose;
let dispose;
add_render_callback(ctx.onlinestatuschanged);
return {
@ -21,12 +20,10 @@ function create_fragment(ctx) {
listen(window, "offline", ctx.onlinestatuschanged)
];
},
m: noop,
p: noop,
i: noop,
o: noop,
d(detaching) {
run_all(dispose);
}
@ -37,7 +34,7 @@ function instance($$self, $$props, $$invalidate) {
let online;
function onlinestatuschanged() {
online = navigator.onLine; $$invalidate('online', online);
$$invalidate("online", online = navigator.onLine);
}
return { online, onlinestatuschanged };

Loading…
Cancel
Save