interfaced / karma-module-resolver-preprocessor

Karma preprocessor to resolve ES6 modules
2 stars 0 forks source link

Bug: import declaration and export declarations not working #2

Open brion-fuller opened 4 years ago

brion-fuller commented 4 years ago

If i have a file like

import { LitElement, html, customElement } from "lit-element";
export * from 'lit-element';
export { LitElement} from 'lit-element';
@customElement("hello-world")
export default class HelloWorld extends LitElement {
  render() {
    await import('lit-element');
    return html`<h1>Hello World</h1>`;
  }
}

Browsers support dynamic imports/named imports and exports. In the example all the imports currently are skipped for rendering.

brion-fuller commented 4 years ago

I have a solution for this but it was writing using @babel/parser. So I wasn't sure your feelings on moving from espree to @babel/parser.

brion-fuller commented 4 years ago

3

l1bbcsg commented 4 years ago

Espree does support dynamic imports it seems, it just requries ecmaVersion above 11 or 2020.

Have you tried that?

l1bbcsg commented 4 years ago

Regarding switching the parser engine, pretty much the main motivation behind this preprocessor was avoiding using bulky libraries like babel to have a minimal impact on host project node_modules.

I see however you now have switched parsing backend to es-module-lexer which looks interesting and in fact seems to be even more in line with the above goal than espree.