prevent accidentally reintroducing ES6 into shared helpers

pull/841/head
Rich Harris 8 years ago
parent f3eeaa9f39
commit 1bdd624b35

@ -55,6 +55,7 @@ export interface CompileOptions {
hydratable?: boolean;
legacy?: boolean;
customElement?: CustomElementOptions | true;
css?: boolean;
onerror?: (error: Error) => void;
onwarn?: (warning: Warning) => void;

@ -16,6 +16,11 @@ fs.readdirSync(__dirname).forEach(file => {
ast.body.forEach(node => {
if (node.type !== 'ExportNamedDeclaration') return;
// check no ES6+ slipped in
acorn.parse(source.slice(node.declaration.start, node.end), {
ecmaVersion: 5
});
const declaration = node.declaration;
if (!declaration) return;
@ -34,5 +39,7 @@ fs.readdirSync(__dirname).forEach(file => {
fs.writeFileSync(
'src/generators/dom/shared.ts',
`// this file is auto-generated, do not edit it
export default ${JSON.stringify(declarations, null, '\t')};`
const shared: Record<string, string> = ${JSON.stringify(declarations, null, '\t')};
export default shared;`
);

Loading…
Cancel
Save