Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Code that is using the object spread operator can't be packaged #206

Closed
pkeuter opened this issue Aug 25, 2017 · 26 comments
Closed

Code that is using the object spread operator can't be packaged #206

pkeuter opened this issue Aug 25, 2017 · 26 comments

Comments

@pkeuter
Copy link

pkeuter commented Aug 25, 2017

For example:

When running pkg index.js:

const testObject = {};
const spreaded = {...testObject};

throws this error:

Error! Unexpected token (2:18)
  index.js

Node handles spread since v8.3: http://node.green/#ESNEXT-candidate--stage-3--object-rest-spread-properties. By default, pkg uses version 8.0.0 of Node, but when passing -t latest, it uses 8.3, I would assume object spread should work when using version 8.3.

@pkeuter pkeuter changed the title code that is using the spread operator can't be packaged Code that is using the spread operator can't be packaged Aug 25, 2017
@pkeuter pkeuter changed the title Code that is using the spread operator can't be packaged Code that is using the object spread operator can't be packaged Aug 25, 2017
@boshido
Copy link

boshido commented Sep 14, 2017

I'm using babel-register too with node version 6.11.2.
For me I faced problem of "..." syntax, it caused pkg throw an error when it found "..." command

> pkg@4.2.4
> Error! Unexpected token (25:84)
  /home/com/app/apis/admin/admin-driver.flow.js

Work fine for running node index.js

@krjj
Copy link

krjj commented Oct 28, 2017

Spread operator does not work with node version 8.6.0

@santimendoza
Copy link

santimendoza commented Dec 4, 2017

I am facing the same issue. Node 8 LTS DO support spread object operator. But when I try to package my project using node8 in pkg, I get a Unexpected token.

Any help or solution?

@Kikobeats
Copy link
Member

same problem :((

@rjhilgefort
Copy link

Facing this problem as well.

@jonathanprl
Copy link

jonathanprl commented Jan 26, 2018

Same here with 8.9.0 and 9.2.1.

 pkg@4.3.0
> Fetching base Node.js binaries to PKG_CACHE_PATH
  fetched-v8.9.0-win-x64       [====================] 100%
> Error! Unexpected token (74:59)

@ramiel
Copy link

ramiel commented Jan 30, 2018

Same here.

@ashking
Copy link

ashking commented Feb 20, 2018

Any solution to this problem?

@kalinkrustev
Copy link

Try setting ecmaVersion to 9 here:
https://github.com/zeit/pkg/blob/master/lib/detector.js#L334

tmende added a commit to kumi-health/pkg that referenced this issue Mar 13, 2018
@SirArslaan
Copy link

Same here

@igorklopov
Copy link
Contributor

I'll be taking care of these shortly, with some more updates coming to pkg. Thank you!

@Kikobeats
Copy link
Member

Love what is ZEIT doing these days for the web in terms of OSS, but definitely, this repository needs more attention.

A Pull Request related to spread operator has merged days ago:
#379

is the PR closing this issue?

We can find at least more than one issue related to spread operator that is not closed:
#352. Why?

The only thing that we have is a message from the main contributor saying "yep, no problem, news coming soon," but what news? Will all the issues be solved magically? why so little information?

Just I want to understand how are you doing to maintain this repository and trying to push forward.

@garthk
Copy link

garthk commented Apr 16, 2018

Fixed in 4.3.1.

@garthk
Copy link

garthk commented Apr 18, 2018

@santimendoza?

@santimendoza
Copy link

@garthk I hadn't test it with that version. I'll test it and let you know

@praneethgayam
Copy link

pkg@4.3.1
Error! Unexpected token (108:20)

@santimendoza
Copy link

It worked for me in the latest version

@estambakio-sc
Copy link

estambakio-sc commented May 28, 2018

4.3.1 still breaks on rest operator when called with node8-linux-x64 and similar win/macos targets.

@Kikobeats
Copy link
Member

Kikobeats commented Jun 21, 2018

Spread object operator is not supported at v4.3.2

> Error! Binding rvalue (18:31)

where the line of code is

module.exports = async ({ url, ...opts }) => {

@igorklopov
Copy link
Contributor

Thanks!

@OysteinAmundsen
Copy link

OysteinAmundsen commented Nov 12, 2019

Still breaks for me:

$ yarn pkg
yarn run v1.19.0
$ pkg . --out-path pkg
> pkg@4.4.0
> Targets not specified. Assuming:
  node12-linux-x64, node12-macos-x64, node12-win-x64
> Error! Unexpected token, expected ";" (11:5)
  D:\dev\app\node_modules\normalize.css\normalize.css
error Command failed with exit code 2.

@arpitprod
Copy link

@OysteinAmundsen any solution? I'm also facing same error

@igorklopov
Copy link
Contributor

@OysteinAmundsen @arpitprod does it fail with require("normalize.css") only? How the code looks like?

@arpitprod
Copy link

@igorklopov yes, this is solution for me

@igorklopov
Copy link
Contributor

@arpitprod ok, but please try pkg@4.4.2 in case no workaround is needed with 4.4.2

@arpitprod
Copy link

it's working fine now after update pkg

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests