Open jcorbin opened 3 years ago
I'm also experiencing this build error. Are there any helpful things we could do to provide support in sorting this out?
I don't know how helpful this might be, but my guess is things are failing on files that are types only.
Hi, sorry for late answer.
I may have an update on this. I think the problem is that the package esprima
(which is used for scanning imports) needs to run on already babel compiled code, see code . That is why I used the optimize
hook. But I guess it does not seems to be that way all the time.
So one solution would be to make it possible to bring your local babel configuration to the esprima function call and pre compile the file before running esprima.
Something like this.
const result = babel.transformFileSync(filepath, babelOptions);
try {
const tree = esprima.parse(result.code, {
sourceType: 'module',
tolerant: true,
})
}
Hey @akejolin thanks for getting back either way 😄
Unfortunately I'm using TypeScript only, so I don't even have a babel configuration to import.
I actually really needed this kind of plugin for a side-project of mine, and I came to realize I really would prefer to have sourceMaps and support for CSS. So I hacked on my own similar snowpack plugin which may or may not be useful to you @jcorbin https://github.com/TylorS/snowpack-plugin-hash.
Thank you for that, @TylorS. It works great in my Snowpack / TypeScript project!
All of my sources fail with an esprima error similar to:
Trying to build a typescript package: https://github.com/borkshop/js/tree/main/packages/jspit