Starting with parcel 1.6, all javascript code is transformed by babel.
Our project (https://github.com/propelml/propel) uses typescript, which already knows how to target different versions of javascript/ecmascript.
Therefore the babel transform is unnecessary -- and it actually creates problems because babel generates code that is dependent on regeneratorRuntime.
Could there be an option to disable the babel transform (either for typescript or for all javascript code)?
I agree. Typescript already handles transpiling code, so it doesn鈥檛 make any sense for us to run that through Babel. It just makes the bundle larger and wastes time duplicating the work that Typescript did.
We should also optimize the way we handle typescript assets too. Maybe we can even take the AST from the TypeScript Compiler API, and pass it into Uglify similar to what do with Babel.
@davidnagli The AST is different from the babel AST, so this would be impossible, however this feature can be achieved by either converting Typescript AST to Babel AST (might be slightly faster if done correctly, but way more complex). Or generate a new AST from the output (kind of what we do now but without the actual transpiling)
I started working on this on the TypeScript plugin, see parcel-plugin-typescript#c511bd.
Babel isn't called once, it's direct TS code -> TS AST -> transformations -> TS AST -> JS
, with a support for fs.readFileSync
, require
, import
, process
and node.js globals.
On my big corporate projects it improves build time by a 1.5 factor.
We can create a PR for this here if you are interested.
Ya I think that would be a great idea.
I never really understood why we have a seperate plugin if we have Typescript support in the core. I think we should merge the plugin鈥檚 features into core and get rid of the plugin.
@devongovett @DeMoorJasper Thoughts?
@davidnagli The direct typescript ast transform would be nice, more predictable as well. About porting over all the plugin features wouldn鈥檛 be a good idea, the plugin seems to go beyond parcels scope, another nice feature the plugin has is typescript error handling (and i don鈥檛 mean the annoying typing warnings, but actual compile-errors)
Sent with GitHawk
Yes please add this feature. Also (and I'm not totally sure if this is related but I think so) Parcel tends to swallow very obvious syntax errors. I love Parcel - but this is a deal breaker for me.
https://github.com/ry/deno/blob/5c7ba22f2242930ad09f011eaea12a59153e294f/deno2/BUILD.gn#L100-L101
Seriously, there needs to be an option to turn off babel. I don't want babel. I'm getting errors left and right because of some exotic libraries that TypeScript can handle to transpile correctly, but babel then messes up.
Is there a way to disable babel via .babelrc? I couldn't find one.
Please don't make me go back to webpack and its insane config.
Parcel compiles code to the specified browser/node version target in your app. It determines this based on the browserslist
or engines.node
keys in package.json depending on the --target
flag. If neither of those are available, a default is picked: > 0.25% marketshare for browsers, or the node LTS version (currently 6). If you want to disable compilation, you can specify higher engine versions in your package.json.
@devongovett I created a .browserslistrc
directly in my project root directory and filled it with
> 1%
last 2 versions
not dead
But unfortunately I'm still getting following error when I try to do a await import('./...');
in my TypeScript
project:
Uncaught ReferenceError: regeneratorRuntime is not defined
It seems that Parcel
is still using Babel and tries to find its regeneratorRuntime
(that I don't use because of TypeScript has everything included for async / await
and dynamic imports)
Same. Is there no workaround for this bug/missing feature ?
hi guyz. First thanks for the huge works, parcel is becoming my bundler n掳1 !
I'd like to add a +1 for this issue.
I'm using typescript for type-checking. That's why I expect parcel to
But as explained here babel is only meant for transportation, not type checking. So typescript looks like the only way to go.
Currently I am using tsc and parcel in concurrent thread, to have all features, as explained in this repo
I think we need to create a bundler which works out of the box with Typescript and doesn鈥檛 use Babel when not needed.
@anjmao there is already one: FuseBox
That's what we need, yet another bundler!
At this moment, the workaround is adding the following lines to the package.json:
"browserslist": [
"last 1 Chrome version"
],
Most helpful comment
Seriously, there needs to be an option to turn off babel. I don't want babel. I'm getting errors left and right because of some exotic libraries that TypeScript can handle to transpile correctly, but babel then messes up.
Is there a way to disable babel via .babelrc? I couldn't find one.
Please don't make me go back to webpack and its insane config.