isaac-mason/recast-navigation-js

Output cjs builds, react-scripts support

eriksachse opened this issue · 4 comments

Repro: https://codesandbox.io/s/sad-dawn-hdq9zf?file=/src/App.js

When using init() within a React app, a syntax Error appears. Cannot use 'import.meta' outside a module

Hi, thanks for the issue & reproduction!

Right now recast-navigation-js only has an ESM build, so importing it in a non-esm project has to be done like this: https://github.com/isaac-mason/recast-navigation-js/blob/de28866dec263433db34799592a5a33808ea511c/examples/node-cjs-recast-navigation-example/src/index.js

I acknowledge this isn't ideal though. I want to support the wider r3f community, many of which use CJS still via tools like react-scripts and parcel, so I'm working on adding cjs builds now.

This should get fixed by 82a1bb1 and 9b8ea41

These will be released shortly

In v0.9.3 support for react-scripts and parcel (and others) should be fixed.

Interestingly, there are still issues importing recast-navigation in the browser codesandbox.

Downloading the sandbox and running it locally, or using a cloud sandbox, there's no issues though: https://codesandbox.io/p/sandbox/recast-navigation-react-scripts-example-8wy6hh

Given this looks like a CodeSandbox-specific issue, I'll close this, and we can track the fix for CodeSandbox here: #145