Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with Embroider? (build-time/dynamic magic?) #12

Open
NullVoxPopuli opened this issue Apr 29, 2020 · 9 comments
Open

Doesn't work with Embroider? (build-time/dynamic magic?) #12

NullVoxPopuli opened this issue Apr 29, 2020 · 9 comments

Comments

@NullVoxPopuli
Copy link

Getting this error:
image

Not sure why though. It looks resolveable (in addon directory).

cc @ef4

@NullVoxPopuli
Copy link
Author

Looks like this is the call site (concat'd vendor.js):
image

@NullVoxPopuli
Copy link
Author

ah, with chrome, I got some more info:
image

@NullVoxPopuli
Copy link
Author

This might be a "fix":
though, I'd really like to know why this is needed in the first place -- maybe there is build-time magic doing something with the /-internal modules?

  return compatBuild(app, Webpack, {
      extraPublicTrees: additionalTrees,
      staticAddonTestSupportTrees: true,
      staticAddonTrees: true,
      staticHelpers: true,
      staticComponents: true,
      // splitAtRoutes: true,
      // skipBabel: [],
      compatAdapters: new Map([
        ['ember-destroyable-polyfill', EmberDestroyableCompatAdapter],
      ]),
    });


// .......

const { V1Addon } = require('@embroider/compat');
const { forceIncludeModule } = require('@embroider/compat/src/compat-utils');

class EmberDestroyableCompatAdapter extends V1Addon {
  get packageMeta() {
    let meta = super.packageMeta;
    meta = forceIncludeModule(meta, './-internal/patch-core-object');
    meta = forceIncludeModule(meta, './-internal/patch-meta');

    return meta;
  }
}

@rwjblue
Copy link
Member

rwjblue commented May 1, 2020

There are a few issues here:

  1. we can avoid needing to require by moving the patch content into vendor/ and setting up transpilation for treeForVendor
  2. we need to figure out what the "right" way to masquerade in Embroider land is since we basically want to provide @ember/destroyable module, but that doesn't really match our expected name. I think we can implement moduleName(){ return '@ember/destroyable'; }?

@ef4
Copy link

ef4 commented May 1, 2020

Yes, moduleName is supported, and probably the least bad way to masquerade. I can show a solution for this addon, but I have a question:

Is the require.has('@ember/destroyable') check redundant with the emberVersion.lt('4.0.0') check? Or are they asking subtly different questions? I would guess they are both just trying to ask the same question, which is "should the polyfill be inert?", but then why have both checks?

@ef4
Copy link

ef4 commented May 1, 2020

Relatedly: what is the plan for shipping native @ember/destroyable? Will it be a package like @glimmer/component or will it another api shim?

I'm guessing shim, because otherwise we wouldn't need a separate polyfill package, we could just make the real package work in older ember versions?

@rwjblue
Copy link
Member

rwjblue commented May 1, 2020

Is the require.has('@ember/destroyable') check redundant with the emberVersion.lt('4.0.0') check?

Yes, I think they are redundant.

What is the plan for shipping native @ember/destroyable? Will it be a package like @glimmer/component or will it another api shim?

It still somewhat TBD (implementation is not done yet), but I would suspect it would be a shim package (like all of the rest of @ember/*).

@rwjblue
Copy link
Member

rwjblue commented Aug 2, 2020

OK, the implementation now matches what other polyfills do. It is a straight up app.import from a vendor file.

@rwjblue
Copy link
Member

rwjblue commented Aug 3, 2020

@NullVoxPopuli - Mind testing the latest release (v2.0.1)? (Note: you must be using [email protected] or higher)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants