embroider-build / ember-auto-import

Zero config import from npm packages
Other
360 stars 109 forks source link

Module build failed after bugfix in package (msw) #559

Open BoussonKarel opened 1 year ago

BoussonKarel commented 1 year ago

Issue

Hi, I just updated msw from 0.49.2 to 0.49.3 and now my build started failing:

Error

...

ERROR in ./node_modules/strict-event-emitter/lib/Emitter.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: C:\Users\Karel\msw-auto-import-bug\node_modules\strict-event-emitter\lib\Emitter.js: Class private methods are not enabled. Please add `@babel/plugin-proposal-private-methods` to your configuration.
  24 |         this.#hasWarnedAboutPotentialMemortyLeak = false;
  25 |     }
> 26 |     #getListeners(eventName) {
     |     ^
  27 |         return this.#events.get(eventName) || [];
  28 |     }
  29 |     #removeListener(listeners, listener) {
    at File.buildCodeFrameError (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\core\lib\transformation\file\file.js:205:12)
    at NodePath.buildCodeFrameError (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\traverse\lib\path\index.js:105:21)
    at shouldTransform (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\helper-create-class-features-plugin\lib\features.js:108:29)
    at PluginPass.Class (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\helper-create-class-features-plugin\lib\index.js:82:44)
    at newFn (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\traverse\lib\visitors.js:143:21)
    at NodePath._call (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\traverse\lib\path\context.js:45:20)
    at NodePath.call (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\traverse\lib\path\context.js:35:17)
    at NodePath.visit (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\traverse\lib\path\context.js:80:31)
    at TraversalContext.visitQueue (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\traverse\lib\context.js:86:16)
    at TraversalContext.visitMultiple (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\traverse\lib\context.js:61:17)
    at TraversalContext.visit (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\traverse\lib\context.js:107:19)
    at traverseNode (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\traverse\lib\traverse-node.js:18:17)
    at NodePath.visit (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\traverse\lib\path\context.js:86:52)
    at TraversalContext.visitQueue (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\traverse\lib\context.js:86:16)
    at run.next (<anonymous>)    at transform (C:\Users\Karel\msw-auto-import-bug\node_modules\@babel\core\lib\transform.js:22:41)    at transform.next (<anonymous>)
    at step (C:\Users\Karel\msw-auto-import-bug\node_modules\gensync\index.js:261:32)    at C:\Users\Karel\msw-auto-import-bug\node_modules\gensync\index.js:273:13
    at async.call.result.err.err (C:\Users\Karel\msw-auto-import-bug\node_modules\gensync\index.js:223:11)
 @ ./node_modules/strict-event-emitter/lib/index.js 1:626-646 @ ./node_modules/msw/lib/index.js 118:77-108
 @ ../AppData/Local/Temp/broccoli-13380PYYd73vg6ots/cache-153-webpack_bundler_ember_auto_import_webpack/app.cjs 15:37-51

Build Error (WebpackBundler)
webpack returned errors to ember-auto-import

Stack Trace and Error Report: C:\Users\Karel\AppData\Local\Temp/error.dump.897292a5a81aaa1fc4ba78a6fac425a2.log

error.dump.ed21c83f59006d777e2b06b69c6cb6d1.log

Reproduction

I have reproduced the error in a new Ember addon: Broken build: https://github.com/BoussonKarel/msw-auto-import-bug Working build: https://github.com/BoussonKarel/msw-auto-import-bug/tree/msw@0.49.2

BoussonKarel commented 1 year ago

It was resolved by the author of strict-event-emitter: https://github.com/open-draft/strict-event-emitter/releases/tag/v0.4.4 by removing the class private methods, but that does not resolve this ember-auto-import bug I guess.

andreyfel commented 1 year ago

It fails now in the same way after msw update to v2.0.

andreyfel commented 1 year ago

@ef4 do you have any thoughts on this?

ef4 commented 1 year ago

The legacy decorators plugin makes several other class-feature plugins mandatory, including @babel/plugin-proposal-private-methods.

We add legacy decorators here: https://github.com/embroider-build/ember-auto-import/blob/843ed86e7fc61c5c29c012738b905a551cb4d49a/packages/ember-auto-import/ts/package.ts#L539

That same spot should add the other plugins that legacy-decorators require. We already have @babel/plugin-proposal-class-properties but we should add @babel/plugin-proposal-private-methods and @babel/plugin-transform-class-static-block.

andreyfel commented 1 year ago

@ef4 please take a look at https://github.com/embroider-build/ember-auto-import/pull/596