...obj
) is failing to work with basic setupNo error
Parcel build
hangs with this syntax error
```
yarn run v1.7.0
$ parcel build index.html
馃毃 Desktop/parcel-spread-bug/src/components/SplitPane.js:74:8: Unexpected token (74:8)
72 | // top
73 | styleA = {
74 | ...baseStyleVertical,
| ^
75 | top: 0,
76 | height: dividerPos + '%',
77 | paddingBottom: 3,
````
Faced this bug here
https://github.com/fkling/astexplorer/pull/330
Repo to reproduce
Interesting:
Removing Google Analytics inline script will resolve the hanging issue
https://github.com/mohsen1/parcel-spread-bug/pull/1
edit
this was a red herring. I'm still not sure why it does not hang
I reduced this bug to simply:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script src="./index.js"></script>
</body>
</html>
index.js
var a = {
foo: 1
};
var b = {
...a,
bar: 2
};
parcel build index.html
prints:
$ parcel build index.html
馃毃 /parcel-spread-bug/index.js:6:2: Unexpected token (6:2)
4 |
5 | var b = {
> 6 | ...a,
| ^
7 | bar: 2
8 | };
9 |
note, it works with --target node
Parcel out of box includes babel-preset-env
and babel-preset-react
. The object rest spread transform is not part of either. So you need to install babel-plugin-transform-object-rest-spread
and define it in your .babelrc
file.
That seems to work:
https://github.com/mohsen1/parcel-spread-bug/pull/2
I wonder why this works in node target though?
Owkeey, so this is not a bug, closing this.
This may not be a bug, but it is so usual that I expected it to be included by default.
@danielo515 It will be in the next release see #1835
Awesome!
Thanks for making parcel even better
So this doesn't work with external dependencies.
This even works in third-party node_modules: if a configuration file is published as part of the package, the transform is automatically turned on for that module only.
— Parcel Docs
Is there a way to transpile third-party node_modules that don't have the configuration file?
Most helpful comment
Parcel out of box includes
babel-preset-env
andbabel-preset-react
. The object rest spread transform is not part of either. So you need to installbabel-plugin-transform-object-rest-spread
and define it in your.babelrc
file.