kensho-technologies / babel-preset Goto Github PK
View Code? Open in Web Editor NEWBabel preset to transpile ES2020, TS(X), and language proposals
License: Apache License 2.0
Babel preset to transpile ES2020, TS(X), and language proposals
License: Apache License 2.0
This would be a convenience, forwarded as pragma
to the React preset and jsxPragma
to the Typescript preset, if either are enabled.
Not sure if it's justifiable as a top-level option.
The runtime transform has an option to use ESM versions of its helpers. We could enable this when {modules: false}
.
Follow-up to #106.
We could use an override to be a bit stricter here, to account for third-party code using a wider range of language features than we do internally. (This will become more common over time as libraries transpile themselves less aggressively.)
We could potentially special case @kensho
packages to use the regular assumptions there.
We currently hardcode a target version of Node for library builds:
Line 35 in 4b37790
We're adding engines
field to all of our projects. This corresponds to the consuming environment so the lowest satisfying version is exactly the one that we'd want as the default Node target when transpiling libraries.
We could try to detect this automatically:
package.json
.engines.node
field.The current snapshot-based is getting unwieldy:
I think we should try out inline snapshots with a new test suite that is more locally-scoped. We can include a few kitchen sink tests to get the high-level integration coverage that our current suite covers as well.
The forced plugin inclusion list is getting pretty long:
Lines 7 to 13 in e87fb8d
Most of it is only necessary for projects using webpack 4. #91 removes it entirely, but we'll likely be split between 4 and 5 for awhile.
We could add something like a webpack
option to the preset to specify the version used by the consuming app. It would only affect development
and production
envs, modifying the forced inclusion list as needed. A simple implementation would take either 4
or 5
. A more advanced implementation would take the full version, since some newer syntax is only supported in more recent versions of 5 (e.g., see the note here).
I also wonder if Babel has considered having babel-loader
do this automatically. NTS to look into that.
We generally don't want to transpile stable features there.
Before the next major release. We no longer use it anywhere.
See the docs and the announcement.
Going forward, this will be the preferred way to override the browserslist env, since it integrates with plugins/presets beyond @babel/preset-env
such as the new polyfill transforms.
Unfortunately, it's not a straightforward migration because the top-level option can't be specified in presets. I opened babel/babel#13317 to see whether this might change. If not, we'll need to add at least some config to each app.
{emotion: true, react: {runtime: 'classic'}}
in 'development'
environment causes Babel to crash:
SyntaxError: /index.js: pragma and pragmaFrag cannot be set when runtime is automatic.
> 1 | import * as React from "react";
| ^
2 |
3 | export default function MyComponent() {
4 | return <div />;
at File.buildCodeFrameError (/node_modules/@babel/core/lib/transformation/file/file.js:250:12)
at NodePath.buildCodeFrameError (/node_modules/@babel/traverse/lib/path/index.js:144:21)
at PluginPass.enter (/node_modules/@babel/helper-builder-react-jsx-experimental/lib/index.js:167:26)
at newFn (/node_modules/@babel/traverse/lib/visitors.js:175:21)
at NodePath._call (/node_modules/@babel/traverse/lib/path/context.js:55:20)
at NodePath.call (/node_modules/@babel/traverse/lib/path/context.js:42:17)
at NodePath.visit (/node_modules/@babel/traverse/lib/path/context.js:92:31)
at TraversalContext.visitQueue (/node_modules/@babel/traverse/lib/context.js:112:16)
at TraversalContext.visitSingle (/node_modules/@babel/traverse/lib/context.js:84:19)
at TraversalContext.visit (/node_modules/@babel/traverse/lib/context.js:140:19) {
code: 'BABEL_TRANSFORM_ERROR'
}
It's caused by a quirk in the way that the Emotion preset supports both runtimes simultaneously: emotion-js/emotion#2082. Not sure if the Emotion behavior will change but it can be fixed here by only setting the development
option of the Emotion preset in the automatic runtime.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.