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

transpile to es2018 #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

mxmul
Copy link

@mxmul mxmul commented Dec 6, 2024

I've been using react-scan in a project with a legacy webpack 4 build, and noticed that the NPM dist uses modern syntax that can't be parsed. To work around, I've been running react-scan through babel-loader, but this PR should fix the problem.

It seems that webpack 4 uses acorn@6 to parse JS, and that it only supports es2018 syntax1. Changing the compilation target for esnext to es2018 fixes the issue, and doesn't affect the build size too much (52kb -> 54kb).

Tested with a trivial webpack 4 config:

Before After
Screenshot 2024-12-05 at 6 58 18 PM Screenshot 2024-12-05 at 6 58 57 PM

Footnotes

  1. https://github.com/acornjs/acorn/blob/6.x/acorn/README.md

Copy link

vercel bot commented Dec 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
react-scan ⬜️ Skipped (Inspect) Dec 6, 2024 0:00am

Copy link

vercel bot commented Dec 6, 2024

Someone is attempting to deploy a commit to the Million Team on Vercel.

A member of the Team first needs to authorize it.

@@ -96,7 +96,7 @@
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"browser": "dist/auto.global.js",
"browser": "dist/index.js",
Copy link
Author

@mxmul mxmul Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webpack prefers the browser field by default. When bundling, I think consumers will generally want the side-effect free module instead of auto.global.js.

@RobPruzan RobPruzan force-pushed the main branch 2 times, most recently from 7526d13 to 47c46ca Compare December 21, 2024 01:52
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

Successfully merging this pull request may close these issues.

1 participant