Skip to content

fix(index-file): fixed the double quote issue #849

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

Merged
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
6 changes: 3 additions & 3 deletions libs/native-federation/src/utils/updateIndexHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export function updateScriptTags(
`;

indexContent = indexContent.replace(
/<script src="(.*?polyfills.*?)><\/script>/,
/<script src="(.*?polyfills.*?)".*?><\/script>/,
'<script type="module" src="$1"></script>'
);
indexContent = indexContent.replace(
/<script src="(.*?main.*?)><\/script>/,
/<script src="(.*?main.*?)".*?><\/script>/,

Choose a reason for hiding this comment

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

If other builders setup other script tag attributes it will break them. Ain't there a way to parse the HTML node as a key value data structure easy to manipulate? 🤔

Copy link
Author

Choose a reason for hiding this comment

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

I like the idea, will have to tinker with the DOMParser and the XMLSerializer

'<script type="module-shim" src="$1"></script>'
);

indexContent = indexContent.replace('<body>', `<body>${htmlFragment}`);
indexContent = indexContent.replace(/(<body.*?>)/, `$1\n\t\t${htmlFragment}`);
return indexContent;
}