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

Hide base path from public URL of rollup-public-assets #2082

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion packages/addon-dev/src/rollup-public-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function publicAssets(
});
const publicAssets: Record<string, string> = filenames.reduce(
(acc: Record<string, string>, v): Record<string, string> => {
const namespace = opts?.namespace ?? join(pkg.name, path);
const namespace = opts?.namespace ?? pkg.name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this mean that all the public assets will just be flattened 🤔 you can't have any structure at all any more

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mansone No, this is just the namespace, that is statically added to any file that is within the assets folder. Let's say the package name is fancy-addon, and its rollup config has addon.publicAssets('src/assets/public'), and it has a file in src/assets/public/foo/bar.jpg. Then before this change the plugin would add this to the package.json:

"public-assets": {
  "./src/assets/public/foo/bar.jpg": "fancy-addon/src/assets/public/foo/bar.jpg"
}

With this PR it would be:

"public-assets": {
  "./src/assets/public/foo/bar.jpg": "fancy-addon/foo/bar.jpg"
}

path in L54 would be src/assets/public in this example (as passed to the plugin), so that gets removed here.


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 @@ -393,7 +393,7 @@ export { SingleFileComponent as default };
let expectNoNamespaceFile = expectFilesAt(inDependency(app, 'v2-addon-no-namespace').dir, { qunit: assert });

expectFile('package.json').json('ember-addon.public-assets').deepEquals({
'./public/thing.txt': '/v2-addon/public/thing.txt',
'./public/thing.txt': '/v2-addon/thing.txt',
});
expectNoNamespaceFile('package.json').json('ember-addon.public-assets').deepEquals({
'./public/other.txt': '/other.txt',
Expand Down