JavaScript for WordPress Forums The WP REST API 2.1.13.02 Setting Up The Project

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #36837
    Juliette Tworsey
    Participant

    Hi Zac,

    First of all, Happy New Year! I haven’t been here for a few months and I’m trying to get back into the swing of immersing myself in this course.

    In following along with 2.1.13.02 I am unable to get Webpack to build successfully after running npm i –save (Node V7.10.1). Instead, I am getting this error:

    ERROR in ./src/index.js
    Module build failed: ReferenceError: Unknown plugin "transform-runtime" specified

    I haven’t encountered this error before and I was wondering if anyone else has, and if so, is there a solution?

    I did try (after some searching) installing babel-preset-stage-2 to see if that would remedy the issue, but it did not resolve the error.

    Thanks so much!

    Juliette

    #36859
    Zac Gordon
    Keymaster

    Hey Juliette!

    Sounds like you just need to install transform-runtime, which helps with preventing code completion.

    If there is a package.json file then you just need to run npm install to pull down everything you need.

    Hope that helps!!!

    #36892
    Juliette Tworsey
    Participant

    Hi Zac!

    That (along with the addition of a .babelrc file) did the trick.

    Thanks so much!

    #36934
    Zac Gordon
    Keymaster

    Oh great!

    Do you think there is something wrong with the code I provided in the examples? Please let me know and I’ll post updates 🙂

    Cheers!
    Zac

    #36960
    Juliette Tworsey
    Participant

    Hi Zac,

    I don’t think that there is anything wrong (that I know of) with the code that you have provided in the examples, though I did have to add a .babelrc file (via a recommendation from Babel https://babeljs.io/docs/plugins/transform-runtime/ ).

    This is what I have added to my .babelrc file:

    
    {
      "presets":
    	[
    		"es2015"
    	],
      "plugins": [
        ["transform-runtime", {
          "helpers": false,
          "polyfill": false,
          "regenerator": true,
          "moduleName": "babel-runtime"
        }]
      ]
    }

    I realize that including es2015 in this file may be redundant(?) due to the fact that es2015 is already listed as a preset in thewebpack-config.js file. I’m relatively new to Webpack so I just put it in there for safe measure. Is this an unneeded action?

    Cheers:-)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.