Skip to content

Conversation

@chenhuang444
Copy link

since data-src is a non-standard attribute, micro-zoe/micro-app does not do anything about it during their js sandbox processing. this causes legayPolyfill to fail

since data-src is a non-standard attribute, micro-zoe/micro-app does not do anything about it
during their js sandbox processing. this causes legayPolyfill to fail
@chenhuang444
Copy link
Author

So we are using @micro-zoe/micro-app (https://github.com/jd-opensource/micro-app) for our micro frontend project, and we came across this issue:

They strip the content of inline scripts and execute it in a Proxied environment, which does not have access to the original <script> tag and data-src attribute.

Submitting a fix for this problem. Also I believe this make the plugin more robust as it does not rely on a getElementById call at runtime

@chenhuang444 chenhuang444 force-pushed the fix/microapp-load-fail branch from d369822 to 2a00ee2 Compare December 17, 2024 18:17
@chenhuang444
Copy link
Author

There is also an issue with replaceInStringLiteral function in that replacing with stringLiteral.value will unescape double quotes and the such. for example

const styleString = "@charset \"UTF-8\";cursor: url(/__vite_dynamic_public_path__/assets/cursor.svg);"

will have the raw as "@charset \"UTF-8\";cursor: url(/__vite_dynamic_public_path__/assets/cursor.svg);" and value as @charset "UTF-8";cursor: url(/__vite_dynamic_public_path__/assets/cursor.svg);

The original method would transform the output into:

const styleString = "@charset "UTF-8";cursor: url(" + window.SOMETHING + "/assets/cursor.svg);"

which is broken due to the unescaped double quotes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant