Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(webpack): add global to new line #8226

Merged
merged 1 commit into from Oct 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/webpack/src/plugins/dynamic-base.ts
Expand Up @@ -21,7 +21,7 @@ export const DynamicBasePlugin = createUnplugin((options: DynamicBasePluginOptio
return
}
const s = new MagicString(code)
s.append(`${options.globalPublicPath} = buildAssetsURL();\n`)
s.append(`\n${options.globalPublicPath} = buildAssetsURL();\n`)
Copy link
Member

Choose a reason for hiding this comment

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

@antfu What do you think about supporting s.appendLine?

Copy link
Member

Choose a reason for hiding this comment

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

We didn't have the concept of line in MagicString, as all operations are index based. I am not sure if this complexity is necessary, giving the fix here is straightforward, while on the other hand we might end up introduce the xxxLine version for every magic string methods.

return {
code: s.toString(),
map: options.sourcemap
Expand Down