|
|
|
@ -62,8 +62,6 @@ export default class Component {
|
|
|
|
|
namespace: string;
|
|
|
|
|
tag: string;
|
|
|
|
|
|
|
|
|
|
properties: Map<string, Node>;
|
|
|
|
|
|
|
|
|
|
instance_script: Node;
|
|
|
|
|
module_script: Node;
|
|
|
|
|
|
|
|
|
@ -72,10 +70,10 @@ export default class Component {
|
|
|
|
|
javascript: string;
|
|
|
|
|
|
|
|
|
|
declarations: string[] = [];
|
|
|
|
|
props: Array<{ name: string, as: string }> = [];
|
|
|
|
|
writable_declarations: Set<string> = new Set();
|
|
|
|
|
initialised_declarations: Set<string> = new Set();
|
|
|
|
|
node_for_declaration: Map<string, Node> = new Map();
|
|
|
|
|
exports: Array<{ name: string, as: string }> = [];
|
|
|
|
|
module_exports: Array<{ name: string, as: string }> = [];
|
|
|
|
|
partly_hoisted: string[] = [];
|
|
|
|
|
fully_hoisted: string[] = [];
|
|
|
|
@ -98,7 +96,6 @@ export default class Component {
|
|
|
|
|
stylesheet: Stylesheet;
|
|
|
|
|
|
|
|
|
|
userVars: Set<string> = new Set();
|
|
|
|
|
templateVars: Map<string, string> = new Map();
|
|
|
|
|
aliases: Map<string, string> = new Map();
|
|
|
|
|
usedNames: Set<string> = new Set();
|
|
|
|
|
|
|
|
|
@ -126,8 +123,6 @@ export default class Component {
|
|
|
|
|
this.stylesheet = new Stylesheet(source, ast, options.filename, options.dev);
|
|
|
|
|
this.stylesheet.validate(this);
|
|
|
|
|
|
|
|
|
|
this.properties = new Map();
|
|
|
|
|
|
|
|
|
|
this.module_script = ast.js.find(script => get_context(script) === 'module');
|
|
|
|
|
this.instance_script = ast.js.find(script => get_context(script) === 'default');
|
|
|
|
|
|
|
|
|
@ -158,7 +153,7 @@ export default class Component {
|
|
|
|
|
this.declarations.push(...props);
|
|
|
|
|
addToSet(this.writable_declarations, this.template_references);
|
|
|
|
|
|
|
|
|
|
this.exports = props.map(name => ({
|
|
|
|
|
this.props = props.map(name => ({
|
|
|
|
|
name,
|
|
|
|
|
as: name
|
|
|
|
|
}));
|
|
|
|
@ -182,12 +177,11 @@ export default class Component {
|
|
|
|
|
return this.aliases.get(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
generate(result: string, options: CompileOptions, {
|
|
|
|
|
banner = '',
|
|
|
|
|
name,
|
|
|
|
|
format
|
|
|
|
|
}) {
|
|
|
|
|
const pattern = /\[✂(\d+)-(\d+)$/;
|
|
|
|
|
generate(result: string) {
|
|
|
|
|
const { options, name } = this;
|
|
|
|
|
const { format = 'esm' } = options;
|
|
|
|
|
|
|
|
|
|
const banner = `/* ${this.file ? `${this.file} ` : ``}generated by Svelte v${"__VERSION__"} */`;
|
|
|
|
|
|
|
|
|
|
const helpers = new Set();
|
|
|
|
|
|
|
|
|
@ -248,6 +242,8 @@ export default class Component {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const pattern = /\[✂(\d+)-(\d+)$/;
|
|
|
|
|
|
|
|
|
|
parts.forEach((str: string) => {
|
|
|
|
|
const chunk = str.replace(pattern, '');
|
|
|
|
|
if (chunk) addString(chunk);
|
|
|
|
@ -528,7 +524,7 @@ export default class Component {
|
|
|
|
|
this.userVars.add(name);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.extract_imports_and_exports(script.content, this.imports, this.exports);
|
|
|
|
|
this.extract_imports_and_exports(script.content, this.imports, this.props);
|
|
|
|
|
|
|
|
|
|
this.javascript = this.extract_javascript(script);
|
|
|
|
|
}
|
|
|
|
|