fails to build when rootURL undefined
function ensureTrailingSlash(url: string): string {
if (url[url.length - 1] !== '/') { // <-------------- Cannot read property 'length' of undefined
url = url + '/';
}
return url;
}
This is called from publicAssetURL which uses rootURL from the project or addon. Project had baseURL defined but not rootURL.
Suggested change:
publicAssetURL(): string {
if (this.isAddon) {
throw new Error(`bug: only the app should control publicAssetURL`);
}
return ensureTrailingSlash(
this.autoImportOptions?.publicAssetURL ??
// ensureTrailingSlash((this._parent as any).config().rootURL) + 'assets/'
ensureTrailingSlash((this._parent as any).config().rootURL ?? '/') + 'assets/'
);
}
Yeah, I think it's OK to default rooURL to / if it's unset.
I would consider it a grey area whether not setting it is really supported, but it happens to work in classic builds so we can follow suit.
Maybe add a deprecation warning. This is most likely a hangover from a very old app that's been upgraded
How did you solve this? I'm on v2.7.2.
If I go to node_modules and edit the package.js file, things work. But then how do I build it?
hello @yandiro
I can tell you about my use case for not having a rootURL set or more precisely for having it be a relative one to where the build is deployed
what I ended up with is rootURL: ''
AND when environment === 'test' fall back onto ENV.rootURL = '/'; or your /tests won't work correctly