-
-
Notifications
You must be signed in to change notification settings - Fork 615
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
build: change rollup target to ES2018 #2419
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Preview in LiveCodesLatest commit: 9e1a9a5
See documentations for usage instructions. |
Probably not related to this, I coincidentally just got a sentry error of a user with an iPad with iOS 12.5.7 so probably one of the 10 years old devices like iPad Air, mini 2 or mini 3 that can't update to iOS 13. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Yeah, I generally avoid omitting ()
to catch, but forgot in these places.
I wonder if there's an eslint rule to prohibit it.
Looks like there isn't (and probably won't be) an official rule for that. eslint/eslint#10264 But there are plugins that provide this rule. Like https://eslint-plugin-es.mysticatea.dev/rules/no-optional-catch-binding.html |
@amirhhashemi diff --git a/rollup.config.js b/rollup.config.js
index 66c8f0e..afd185f 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -33,10 +33,11 @@ function getBabelOptions(targets) {
}
}
-function getEsbuild(target, env = 'development') {
+function getEsbuild(env = 'development') {
return esbuild({
minify: env === 'production',
- target,
+ target: 'es2018',
+ supported: { 'import-meta': true },
tsconfig: path.resolve('./tsconfig.json'),
})
}
@@ -78,7 +79,7 @@ function createESMConfig(input, output, clientOnly) {
delimiters: ['\\b', '\\b(?!(\\.|/))'],
preventAssignment: true,
}),
- getEsbuild('node12'),
+ getEsbuild(),
banner2(() => clientOnly && cscComment),
],
}
@@ -157,7 +158,7 @@ function createSystemConfig(input, output, env, clientOnly) {
delimiters: ['\\b', '\\b(?!(\\.|/))'],
preventAssignment: true,
}),
- getEsbuild('node12', env),
+ getEsbuild(env),
banner2(() => clientOnly && cscComment),
],
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b865bda
to
9e1a9a5
Compare
@dai-shi Yeah I think it works. I reverted the old commit and just changed the rollup config. Before: $ yarn run build
$ grep -o 'catch{' ./dist/**/*.js
./dist/system/vanilla/utils.production.js:catch{
./dist/system/vanilla/utils.production.js:catch{
./dist/system/vanilla/utils.production.js:catch{ After: $ yarn run build
$ grep -o 'catch{' ./dist/**/*.js
# There is no 'catch{` in the build output |
btw you want to grep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change.
(We should probably do the same for Zustand and Valtio.)
Isn't the build output minified? |
No, for esm and cjs builds, we don't minify. |
I tried $ grep -o 'catch {' ./dist/**/*.js
./dist/system/vanilla/utils.development.js:catch {
./dist/system/vanilla/utils.development.js:catch { After: $ grep -o 'catch {' ./dist/**/*.js
# There is no 'catch {` in the build output |
Interesting. I get this:
|
Wired. I tried it again and it seems to be working. I even tried a grep that covers more scenarios: Did you run |
This isn't super important, but just curious. I run $ grep 'catch {' dist/esm/vanilla/utils.mjs
} catch {
} catch { |
|
Related Issues or Discussions
#48
Summary
Jotai causes a very hard to debug syntax error in browsers that don't support ES2019. I tracked down the issue to the two
catch
blocks that use Optional catch Binding. Optional catch Binding was introduced in ES2019 and is not supported in Chrome 65 and older. This PR fixes that.Browser support: https://caniuse.com/mdn-javascript_statements_try_catch_optional_catch_binding
Check List
yarn run prettier
for formatting code and docs