Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output cjs builds, react-scripts support #140

Closed
eriksachse opened this issue Sep 22, 2023 · 4 comments
Closed

Output cjs builds, react-scripts support #140

eriksachse opened this issue Sep 22, 2023 · 4 comments

Comments

@eriksachse
Copy link

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

@isaac-mason isaac-mason changed the title Cannot use 'import.meta' outside a module Output cjs builds Sep 23, 2023
@isaac-mason
Copy link
Owner

isaac-mason commented Sep 23, 2023

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.

@isaac-mason isaac-mason changed the title Output cjs builds Output cjs builds, react-scripts support Sep 23, 2023
@isaac-mason
Copy link
Owner

isaac-mason commented Sep 23, 2023

This should get fixed by 82a1bb1 and 9b8ea41

These will be released shortly

@isaac-mason
Copy link
Owner

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

@isaac-mason
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants