sindresorhus / p-event

Promisify an event by waiting for it to be emitted

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jest fails on tests: Cannot use import statement outside a module

OnkelTem opened this issue · comments

After updating to 5.0.1 my tests fail:

 /path/to/project/node_modules/p-event/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import pTimeout from 'p-timeout';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module

Ah that. I see.

Well, I honestly tried to use ESM, I did my best to migrate to ESM but... I failed, even for some new projects.

I spent several weeks on that, learning and investigating, talking to people, but only to... finally confess that I cannot get it working.

And even if I could, even if I had made my project obscured all these weird .mts extensions or odd .js imports and etc — at the end of the count — I saw not a single advantage of this "new system". Sorry.

I think we can close it then.