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

fix(plugin-legacy): empty base makes import fail (fixes #4212) #8387

Merged
merged 1 commit into from
May 29, 2022
Merged
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
4 changes: 3 additions & 1 deletion packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
chunk.facadeModuleId
)
if (legacyEntryFilename) {
// `assets/foo.js` means importing "named register" in SystemJS
const nonBareBase = config.base === '' ? './' : config.base
tags.push({
tag: 'script',
attrs: {
Expand All @@ -427,7 +429,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
// script content will stay consistent - which allows using a constant
// hash value for CSP.
id: legacyEntryId,
'data-src': config.base + legacyEntryFilename
'data-src': nonBareBase + legacyEntryFilename
},
children: systemJSInlineCode,
injectTo: 'body'
Expand Down