scottcharlesworth / laravel-mix-polyfill

A Laravel Mix extension to include polyfills by using Babel, core-js, and regenerator-runtime
MIT License
50 stars 7 forks source link

Dependencies not found: core-js/modules/es6.array.iterator, etc. #15

Open mortenege opened 5 years ago

mortenege commented 5 years ago

I installed via npm install --save laravel-mix-polyfill

// webpack.mix.js

mix.js('resources/js/app.js', 'public/js')
  .sass('resources/sass/app.scss', 'public/css')
  .polyfill({
      enabled: true,
      useBuiltIns: "usage",
      targets: {"ie": 11},
      debug: true,
      corejs: 2, 
   });
// package.json
    "dependencies": {
        "axios": "^0.18",
        "bootstrap": "^4.1.0",
        "cross-env": "^5.1",
        "jquery": "^3.2",
        "laravel-mix": "^4.0.7",
        "lodash": "^4.17.5",
        "popper.js": "^1.12",
        "resolve-url-loader": "^2.3.1",
        "sass": "^1.22.1",
        "sass-loader": "^7.1.0",
        "vue": "^2.5.17",
        "vue-svg-loader": "^0.12.0",
        "vue-template-compiler": "^2.6.10",
        "laravel-mix-polyfill": "^1.0.2",
        "vue-select": "^3.1.0",
        "vuex": "^3.1.1"
    }

Exceptions when running npm run hot

 ERROR  Failed to compile with 11 errors                                                                                         13:26:31

These dependencies were not found:

* core-js/modules/es6.array.iterator in ./resources/js/QuestionMixin.js
* core-js/modules/es6.function.name in ./resources/js/QuestionMixin.js
* core-js/modules/es6.number.constructor in ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/MachineInput.vue?vue&type=script&lang=js&, ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/ProgressBar.vue?vue&type=script&lang=js&
* core-js/modules/es6.object.to-string in ./resources/js/app.js, ./resources/js/QuestionMixin.js
* core-js/modules/es6.regexp.match in ./node_modules/babel-loader/lib??ref--4-0!./node_modules/vue-loader/lib??vue-loader-options!./resources/js/components/Overview.vue?vue&type=script&lang=js&
* core-js/modules/es6.regexp.to-string in ./resources/js/app.js, ./resources/js/QuestionMixin.js
* core-js/modules/es7.object.values in ./resources/js/QuestionMixin.js
* core-js/modules/web.dom.iterable in ./resources/js/QuestionMixin.js

To install them, you can run: npm install --save core-js/modules/es6.array.iterator core-js/modules/es6.function.name core-js/modules/es6.number.constructor core-js/modules/es6.object.to-string core-js/modules/es6.regexp.match core-js/modules/es6.regexp.to-string core-js/modules/es7.object.values core-js/modules/web.dom.iterable
scottcharlesworth commented 5 years ago

@mortenege can you run npm list --depth=0 and post the results?

mortenege commented 5 years ago
+-- axios@0.18.1
+-- bootstrap@4.3.1
+-- cross-env@5.2.0
+-- jquery@3.4.1
+-- laravel-mix@4.0.16
+-- laravel-mix-polyfill@1.0.2
+-- lodash@4.17.11
+-- popper.js@1.15.0
+-- resolve-url-loader@2.3.2
+-- sass@1.22.1
+-- sass-loader@7.1.0
+-- vue@2.6.10
+-- vue-select@3.1.0
+-- vue-svg-loader@0.12.0
+-- vue-template-compiler@2.6.10
`-- vuex@3.1.1
dariaspark commented 5 years ago

Had the same issue, Installing latest core-js and adding the option corejs: 3 fixed it for me. Also I've added this plugin: https://warlord0blog.wordpress.com/2018/08/01/i-hate-internet-explorer/

1isten commented 5 years ago

npm install --save @babel/polyfill then npm run dev again solves this issue.

Just make sure @babel/polyfill is inside the dependencies(not devDependencies) of your package.json and its up-to-date. In my case I'm using the "^7.4.4" and every thing works fine.

// package.json

...
"devDependencies": {
    "laravel-mix": "^4.1.2",
    "laravel-mix-polyfill": "^1.1.0"
}
...
"dependencies": {
    "@babel/polyfill": "^7.4.4"
}
...

The core-js is included in @babel/polyfill, and you don't have to modify the corejs option.

Also make sure the laravel-mix and laravel-mix-polyfill are up-to-date.