diff --git a/packages/addon-dev/README.md b/packages/addon-dev/README.md index 1c63cb344..bcb121123 100644 --- a/packages/addon-dev/README.md +++ b/packages/addon-dev/README.md @@ -20,7 +20,7 @@ For a guide on porting a V1 addon to V2, see https://github.com/embroider-build/ ### addon.publicAssets(path , 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 diff --git a/packages/addon-dev/src/rollup-public-assets.ts b/packages/addon-dev/src/rollup-public-assets.ts index 2c59834d7..10aabb5bb 100644 --- a/packages/addon-dev/src/rollup-public-assets.ts +++ b/packages/addon-dev/src/rollup-public-assets.ts @@ -51,9 +51,9 @@ export default function publicAssets( }); const publicAssets: Record = filenames.reduce( (acc: Record, v): Record => { - 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; }, {} diff --git a/tests/scenarios/v2-addon-dev-test.ts b/tests/scenarios/v2-addon-dev-test.ts index cbf9f1b73..7f2dba9ce 100644 --- a/tests/scenarios/v2-addon-dev-test.ts +++ b/tests/scenarios/v2-addon-dev-test.ts @@ -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', }); }); });