Fix ES module build of rollup plugin #12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/es-module"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This commit fixes issue lezer-parser/lezer#30.
The problem is that the generated rollup plugin imported
buildParserFilefrom the parent directory index. This is not allowed in ES modules as file extensions are mandatory. A solution was to use the--experimental-specifier-resolution=nodeflag with node, for which support was dropped in Node v19. This issue resurfaced for me while trying to use the plugin with the most recent version ofvite.#9 tried fixing the issue, by simply importing the
index.tsfile. Problem there was that all dependencies were marked external in the rollup config, resulting in the import being copied verbatim and a broken rollup plugin.Here we change the relative import to an import of the
@lezer/generatorpackage.(I considered using
./index.jssince that is the ES module output file, but that I presume would break when using the cjs artifacts, since the import is not touched by rollup and not rewritten to the, then correctindex.cjs.)There is no guarantee that
@lezer/generatoris going to point at the package itself. If you, for example, check out that package on its own, it won't be able to resolve this.Pull request closed