stefanpenner / es6-promise

A polyfill for ES6-style Promises

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't resolve 'vertx'

luke-robertson opened this issue · comments

iv tried doing the

new webpack.IgnorePlugin(/vertx/)

not working for me

Module not found: Error: Can't resolve 'vertx' in '/*******/node_modules/es6-promise/dist'
 @ ./node_modules/es6-promise/dist/es6-promise.js 138:16-26
 @ ./client/src/App.jsx
 @ ./client/src/routes.jsx
 @ ./client/src/index.jsx
 @ multi ./client/src/index
webpack: Compiled with warnings.```

Got the same thing today

new webpack.IgnorePlugin(/vertx/)

sounds like a webpack bug?

@stefanpenner I just found this issue today. Any updates on a fix?

commented

Looks like it's a problem here

function attemptVertx() {
  try {
    var r = require;
    var vertx = r('vertx');
    vertxNext = vertx.runOnLoop || vertx.runOnContext;
    return useVertxTimer();
  } catch (e) {
    return useSetTimeout();
  }
}
commented

That's true. I'm getting the same issue here.
Still not getting what happened.

Still not getting what happened.

@pablohpsilva webpack appears to not respect browserifies browser field in this projects package.json. Yes webpack is not browserify, but it either should support this how provide some alternative (ideally support).

es6-promise/package.json

Lines 53 to 55 in e1bb7b6

"browser": {
"vertx": false
},

@TheLarkInn is it intended for webpack to not support this? I suspect if it did, it would support even more browserify-safe packages. If not, is there another configuration based approach which could be used?

Alternatively, is there some heuristic we can rely on to require but without webpack getting confused?

@TheLarkInn friendly ping

I think package.js may be used for this, must investigate further (moment.js has this...)

So, I gave this a whirl. But am unable to reproduce. Here is my attempt: https://github.com/stefanpenner/test-es6-promise-webpack

If someone can help make my reproduction fail, I can likely configure webpack appropriately, more then likely via:

// webpack.config.js
module.exports = {
  externals: {
    vertex: /** magic **/
  }
}

Unfortunately without reproduction, I have no way to confirm. So if ya'll can help me with ^, I'll land the fix.

I was able to reproduce, required --target=node to my reproduction

i just had the same issue & figured out what was going on.
I have the following structure:

/project:
  /package.json
  /fileA.js -> require('some_lib')
  /subProject
    package.json
    /fileB.js -> require('../fileA.js')

when webpack was compiling subproject, it noticed i was requiring an external dependency & throwed the vertex the warning.
I solved by changing the logic in fileA to inject the dependencies.
so fileA looks like this:

module.exports = ({some_lib}) => (params) => logic

and file B like this:

const some_lib = require('some_lib')
const fileA = require('../fileA.js');
module.exports = params => fileA({some_lib})(params)
commented

Hello everyone. I solved my issue with this lib in some different way. Since I was creating a lib, I moved from webpack to rollup and instead of importing the webcomponent package (this package was my original problem where I ended up here on this issue) I imported in my project just the files I needed and used another es6-promise polyfill.

But this error is super annoying.

Hello there, I have the same issue with auth0-js (auth0/auth0.js#1250), does anyone know how I can fix it? I'm migrating from vue-cli-service to Vite (rollup) for work.

Thank you