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

Better defaults for publicEntrypoints and appReexports #209

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions files/__addonLocation__/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,22 @@ export default {
plugins: [
// These are the modules that users should be able to import from your
// addon. Anything not listed here may get optimized away.
addon.publicEntrypoints(['components/**/*.js', 'index.js'<% if (typescript) {%>, 'template-registry.js'<% } %>]),
// By default all your JavaScript modules (**/*.js) will be importable.
// But you are encouraged to tweak this to only cover the modules that make
// up your addon's public API. Also make sure your package.json#exports
// is aligned to the config here.
// See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon
addon.publicEntrypoints(['**/*.js', 'index.js'<% if (typescript) {%>, 'template-registry.js'<% } %>]),

// These are the modules that should get reexported into the traditional
// "app" tree. Things in here should also be in publicEntrypoints above, but
// not everything in publicEntrypoints necessarily needs to go here.
addon.appReexports(['components/**/*.js']),
addon.appReexports([
'components/**/*.js',
'helpers/**/*.js',
'modifiers/**/*.js',
'services/**/*.js',
]),

// Follow the V2 Addon rules about dependencies. Your code can import from
// `dependencies` and `peerDependencies` as well as standard Ember-provided
Expand Down
13 changes: 7 additions & 6 deletions tests/rollup-build-tests/explicit-imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ describe(`rollup-build | explicit-imports`, () => {
expect(files).to.include(
file,
`expected ${file} to be included in the expected list of files: ${expected.join(
' '
)}, however, only ${files.join(', ')} were found.`
' ',
)}, however, only ${files.join(', ')} were found.`,
);
}
}

hasEachOf(await dirContents(distDir), [
'_app_',
'components',
'services',
'index.js',
'index.js.map',
'template-registry.js',
Expand All @@ -72,10 +73,10 @@ describe(`rollup-build | explicit-imports`, () => {
'template-registry.d.ts.map',
]);

expect(await dirContents(path.join(distDir, 'services'))).to.deep.equal(
[],
'my-service.js is not in the app-re-exports'
);
expect(await dirContents(path.join(distDir, 'services'))).to.deep.equal([
'my-service.js',
'my-service.js.map',
]);
expect(await dirContents(path.join(declarationsDir, 'services'))).to.deep.equal([
'my-service.d.ts',
'my-service.d.ts.map',
Expand Down