embroider-build / embroider

Compiling Ember apps into spec-compliant, modern Javascript.
MIT License
333 stars 136 forks source link

@babel/plugin-transform-runtime not applying to imported modules #1351

Open bendemboski opened 1 year ago

bendemboski commented 1 year ago
  1. Create a new application (I used ember-cli@4.10.0) and set it up to build with embroider
  2. ember serve
  3. Navigate to localhost:4200

In the devtools open /app.js and observe that it imports /node_modules/@babel/runtime/helpers/esm/defineProperty.js, then open /node_modules/@glimmer/component/-private/component.js and observe that it defines a _defineProperty function (and others) inline.

Similarly, if you make the app import from tracked-built-ins, its files will include inline _definePropertys, so it looks like no imported modules have @babel/plugin-transform-runtime applied, while modules in the app itself do.

Was #614 meant to apply to imported modules as well as app modules? Or is there a reason we're not applying it to imported modules?

ef4 commented 1 year ago

The first thing to check here is whether the inline helpers are getting emitted in the first stage (when v1 addons get rewritten to v2) or in the last stage (when the whole app gets built by webpack). You can check by seeing if they're already in there in the copies of the addons present in the tempdir that gets printed as "Building into... " as the build starts.

bendemboski commented 1 year ago

@ef4 yes, the inline helpers are present in the <that temp dir>/node_modules/@glimmer/component/-private/component.js