remove some more unused code

pull/1864/head
Rich Harris 7 years ago
parent d704bac8e7
commit 5c2e945db2

@ -116,16 +116,7 @@ export default class Component {
properties: Map<string, Node>;
defaultExport: Node;
imports: Node[];
shorthandImports: ShorthandImport[];
helpers: Set<string>;
components: Set<string>;
events: Set<string>;
methods: Set<string>;
animations: Set<string>;
transitions: Set<string>;
actions: Set<string>;
namespace: string;
hasComponents: boolean;
javascript: string;
@ -172,14 +163,6 @@ export default class Component {
this.options = options;
this.imports = [];
this.shorthandImports = [];
this.helpers = new Set();
this.components = new Set();
this.events = new Set();
this.methods = new Set();
this.animations = new Set();
this.transitions = new Set();
this.actions = new Set();
this.declarations = [];
this.exports = [];
@ -300,7 +283,7 @@ export default class Component {
const sharedPath = options.shared || 'svelte/internal.js';
const module = wrapModule(result, format, name, options, banner, sharedPath, importedHelpers, this.imports, this.shorthandImports, this.source);
const module = wrapModule(result, format, name, options, banner, sharedPath, importedHelpers, this.imports, this.source);
const parts = module.split('✂]');
const finalChunk = parts.pop();

@ -36,13 +36,6 @@ export default class EachBlock extends Node {
unpackDestructuring(this.contexts, info.context, '');
this.contexts.forEach(context => {
if (component.helpers.has(context.key.name)) {
component.warn(context.key, {
code: `each-context-clash`,
message: `Context clashes with a helper. Rename one or the other to eliminate any ambiguity`
});
}
this.scope.add(context.key.name, this.expression.dependencies);
});

@ -82,7 +82,7 @@ export default class Expression {
const dependencies = new Set();
const contextual_dependencies = new Set();
const { code, helpers } = component;
const { code } = component;
let { map, scope: currentScope } = createScopes(info);
@ -114,15 +114,6 @@ export default class Expression {
return;
}
if (component.helpers.has(name)) {
let object = node;
while (object.type === 'MemberExpression') object = object.object;
const alias = component.templateVars.get(`helpers-${name}`);
if (alias !== name) code.overwrite(object.start, object.end, alias);
return;
}
expression.usesContext = true;
if (!isSynthetic && !isEventHandler) {

@ -20,7 +20,7 @@ export default class DocumentWrapper extends Wrapper {
// TODO verify that it's a valid callee (i.e. built-in or declared method)
component.addSourcemapLocations(handler.expression);
const isCustomEvent = component.events.has(handler.name);
const isCustomEvent = false; // TODO!!!
let usesState = handler.dependencies.size > 0;

@ -43,7 +43,7 @@ export default class WindowWrapper extends Wrapper {
// TODO verify that it's a valid callee (i.e. built-in or declared method)
component.addSourcemapLocations(handler.expression);
const isCustomEvent = component.events.has(handler.name);
const isCustomEvent = false; // TODO!!!
let usesState = handler.expression.dependencies.size > 0;
@ -58,7 +58,7 @@ export default class WindowWrapper extends Wrapper {
block.addVariable(handler_name);
block.builders.hydrate.addBlock(deindent`
${handler_name} = %events-${handler.name}.call(#component, window, function(event) {
${handler_name} = ctx.${handler.name}.call(#component, window, function(event) {
(${handler_body})(event);
});
`);

@ -1,6 +1,6 @@
import deindent from '../utils/deindent';
import list from '../utils/list';
import { CompileOptions, ModuleFormat, Node, ShorthandImport } from '../interfaces';
import { CompileOptions, ModuleFormat, Node } from '../interfaces';
interface Dependency {
name: string;
@ -19,10 +19,9 @@ export default function wrapModule(
sharedPath: string,
helpers: { name: string, alias: string }[],
imports: Node[],
shorthandImports: ShorthandImport[],
source: string
): string {
if (format === 'es') return es(code, name, options, banner, sharedPath, helpers, imports, shorthandImports, source);
if (format === 'es') return es(code, name, options, banner, sharedPath, helpers, imports, source);
const dependencies = imports.map((declaration, i) => {
const defaultImport = declaration.specifiers.find(
@ -59,16 +58,7 @@ export default function wrapModule(
}
return { name, statements, source: declaration.source.value };
})
.concat(
shorthandImports.map(({ name, source }) => ({
name,
statements: [
`${name} = (${name} && ${name}.__esModule) ? ${name}["default"] : ${name};`,
],
source,
}))
);
});
if (format === 'amd') return amd(code, name, options, banner, dependencies);
if (format === 'cjs') return cjs(code, name, options, banner, sharedPath, helpers, dependencies);
@ -87,7 +77,6 @@ function es(
sharedPath: string,
helpers: { name: string, alias: string }[],
imports: Node[],
shorthandImports: ShorthandImport[],
source: string
) {
const importHelpers = helpers.length > 0 && (
@ -100,15 +89,10 @@ function es(
.join('\n')
);
const shorthandImportBlock = shorthandImports.length > 0 && (
shorthandImports.map(({ name, source }) => `import ${name} from ${JSON.stringify(source)};`).join('\n')
);
return deindent`
${banner}
${importHelpers}
${importBlock}
${shorthandImportBlock}
${code}
export default ${name};`;

@ -68,11 +68,6 @@ export interface CompileOptions {
nestedTransitions?: boolean;
}
export interface ShorthandImport {
name: string;
source: string;
};
export interface Visitor {
enter: (node: Node) => void;
leave?: (node: Node) => void;

Loading…
Cancel
Save