Dynamic import, within an addon, of an addon file?

Hello!

I have an add-on that wraps a rather large package. Dynamically importing that package is working as expected. I’m interested in dynamically importing a file within my addon that imports and configures a class exported from the package.

I have the code setup:

// `@org/scheduler` is the package name
// `views/audits/schedule` is the location of the file within /addon
this.AuditScheduleClass = (
    await import('@org/scheduler/views/audits/schedule')
).default;

I should also note that the file itself is a typescript file.

It looks as if ember-auto-import is not generating the dynamic import for that file. I imagine it’s skipping it because of some dependency/devDependency rule? Has anyone else done this?

Also, does doing this actually get me any bundle savings? Does ember-cli just gobble up everything within addon and add it to the vendor payload anyway?

Thanks for the help!

can you expand on this? how do you know?

it might not – it ends up being a webpack (or whatever packager)'s decision about whether or not it makes sense to bundle that file or not – and it wouldn’t come in to play at all unless the consuming app is using embroider in full strict mode (or if your addon is a v2 addon)