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

add babel-polyfill #146

Merged
merged 2 commits into from
Jul 18, 2016
Merged

add babel-polyfill #146

merged 2 commits into from
Jul 18, 2016

Conversation

jtremback
Copy link
Contributor

I want to use async/await again

@tcoulter tcoulter modified the milestones: v3.0.0, v2.0.0 - Break out and modularize May 26, 2016
@lucasconstantino
Copy link

lucasconstantino commented Jun 1, 2016

Meanwhile you can re-configure babel-register in your "truffle.js" file, like so:

require("babel-polyfill");
require("babel-register")({
  "presets": ["es2015"],
  "plugins": ["syntax-async-functions","transform-regenerator"]
});

module.exports = {
  build: {
    "index.html": "index.html",
    "app.js": [
      "javascripts/app.js"
    ],
    "app.css": [
      "stylesheets/app.css"
    ],
    "images/": "images/"
  },
  deploy: [
    // "Contract"
  ],
  rpc: {
    host: "localhost",
    port: 8545
  }
};

(ref: http://masnun.com/2015/11/11/using-es7-asyncawait-today-with-babel.html)

@tcoulter
Copy link
Contributor

tcoulter commented Jun 6, 2016

I've hand-merged this into the develop branch, which includes the migrations branch changes. Can you guy ensure it's working as you expect? Note the migrations branch includes significant changes to Truffle and requires changes in your dapp. See here for more info: #143

@tcoulter
Copy link
Contributor

tcoulter commented Jun 6, 2016

Please close if this works for you so it updates the milestone.

@tcoulter
Copy link
Contributor

tcoulter commented Jun 6, 2016

I've found that this addition breaks testing (and likely other things):

Error: Couldn't find preset "es2015" relative to directory "/Users/tim/Documents/workspace/Consensys/test"

This is likely because of this code added:

require("babel-register")({
  "presets": ["es2015", "stage-2"]
})
require("babel-polyfill")

I've changed it to this, and left it up to the user to specify their presets in their project's .babelrc.

require("babel-register");
require("babel-polyfill");

@tcoulter
Copy link
Contributor

tcoulter commented Jun 6, 2016

@lucasconstantino I really like your solution instead. Perhaps that should be the solution for all truffle projects that want to use babel. The Truffle requirement on babel is overkill since Truffle doesn't use babel internally.

@ethers
Copy link

ethers commented Jun 15, 2016

thanks @lucasconstantino solution works for me

@tcoulter tcoulter merged commit e8d3364 into trufflesuite:master Jul 18, 2016
@cdyfng
Copy link

cdyfng commented Jun 9, 2017

You can update your node to the newest version by following step.

1. node -v     #may display version less then v8.0.0
2. sudo npm cache clean -f 
3. sudo npm install -g n
4. node -v  #check the version , mine is v8.0.0 now 

Test ok on Mac Os.
Then you can use async/await in your js code.

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

Successfully merging this pull request may close these issues.

5 participants