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(build): make SystemJSWrapRE match lazy #16633

Merged
merged 1 commit into from May 13, 2024
Merged

Conversation

AfireHong
Copy link
Contributor

@AfireHong AfireHong commented May 8, 2024

Description

fix: #16632

When build.rollupOptions.compact is set to true, /System.register\(. *(\(exports\)|\(\))/g will match to the first line of ( ).
image

const code = `System.register([],(function(exports){'use strict';return{execute:(function(){var __vite_style__ = document.createElement('style');__vite_style__.textContent = "\n.read-the-docs[data-v-1d5be6d4] {\n  color: #888;\n}\n\n.logo[data-v-58aba71c] {\n  height: 6em;\n  padding: 1.5em;\n  will-change: filter;\n  transition: filter 300ms;\n}\n.logo[data-v-58aba71c]:hover {\n  filter: drop-shadow(0 0 2em #646cffaa);\n}\n.logo.vue[data-v-58aba71c]:hover {\n  filter: drop-shadow(0 0 2em #42b883aa);\n}\n";document.head.appendChild(__vite_style__);/**
* @vue/shared v3.4.27`;
const res = code.replace(/System.register\(.*(\(exports\)|\(\))/g, (match, s1) => {
    console.log(s1) // '()'
})

It will incorrectly take (export, module) as argument to the execute function.
image

Copy link

stackblitz bot commented May 8, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@bluwy bluwy changed the title fix(plugin-legacy): completeSystemWrapPlugin RegExp fix(build): make SystemJSWrapRE match lazy May 13, 2024
@bluwy bluwy added the p3-minor-bug An edge case that only affects very specific usage (priority) label May 13, 2024
@bluwy bluwy merged commit 6583ad2 into vitejs:main May 13, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
2 participants