Skip to content

Commit

Permalink
Merge pull request #1874 from embroider-build/fix-namespace
Browse files Browse the repository at this point in the history
with namespace in publicAssets don't include path
  • Loading branch information
ef4 authored Apr 10, 2024
2 parents e874289 + 8e64043 commit 15c54f0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/addon-dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For a guide on porting a V1 addon to V2, see https://github.com/embroider-build/

### addon.publicAssets(path <required>, options)

A rollup plugin to expose a folder of assets. `path` is a required to define which folder to expose. `options.include` is a glob pattern passed to `walkSync.include` to pick files. `options.exlude` is a glob pattern passed to `walkSync.ignore` to exclude files. `options.namespace` is the namespace to expose files, defaults to the package name
A rollup plugin to expose a folder of assets. `path` is a required to define which folder to expose. `options.include` is a glob pattern passed to `walkSync.include` to pick files. `options.exlude` is a glob pattern passed to `walkSync.ignore` to exclude files. `options.namespace` is the namespace to expose files, defaults to the package name + the path that you provided e.g. if you call `addon.publicAssets('public')` in a v2 addon named `super-addon` then your namespace will default to `super-addon/public`.

## addon-dev command

Expand Down
6 changes: 3 additions & 3 deletions packages/addon-dev/src/rollup-public-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export default function publicAssets(
});
const publicAssets: Record<string, string> = filenames.reduce(
(acc: Record<string, string>, v): Record<string, string> => {
acc[`./${path}/${v}`] = resolve(
'/' + join(opts?.namespace ?? pkg.name, path, v)
);
const namespace = opts?.namespace ?? join(pkg.name, path);

acc[`./${path}/${v}`] = resolve('/' + join(namespace, v));
return acc;
},
{}
Expand Down
2 changes: 1 addition & 1 deletion tests/scenarios/v2-addon-dev-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export { SingleFileComponent as default };
'./public/thing.txt': '/v2-addon/public/thing.txt',
});
expectNoNamespaceFile('package.json').json('ember-addon.public-assets').deepEquals({
'./public/other.txt': '/public/other.txt',
'./public/other.txt': '/other.txt',
});
});
});
Expand Down

0 comments on commit 15c54f0

Please sign in to comment.