Skip to content

Commit

Permalink
fix(lib-external):fix the cCode replacement to fix the external libra…
Browse files Browse the repository at this point in the history
…ry's error
  • Loading branch information
He110te4m committed Jul 17, 2023
1 parent e8c63fd commit b1e69ff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/dev-externals-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ export const devExternalsMixin = {
},
configResolved(resolvedConfig) {
const VALID_ID_PREFIX = `/@id/`;
const reg = new RegExp(`${VALID_ID_PREFIX}(${federationBuilder.externals.join('|')})`, 'g');
const reg = new RegExp(
`(?<quote>["\']).*?${VALID_ID_PREFIX}(${federationBuilder.externals.join('|')})\\k<quote>`,
'g'
);
resolvedConfig.plugins.push({
name: 'vite-plugin-ignore-static-import-replace-idprefix',
transform: (code) => (reg.test(code) ? code.replace(reg, (m, s1) => s1) : code),
transform: (code) =>
reg.test(code) ? code.replace(reg, (_m, quote, libName) => quote + libName + quote) : code,
});
},
resolveId: (id) => {
Expand Down

0 comments on commit b1e69ff

Please sign in to comment.