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

Bug:es-module-shims cause CSS inject code failed #48

Open
langren1353 opened this issue Aug 7, 2022 · 1 comment
Open

Bug:es-module-shims cause CSS inject code failed #48

langren1353 opened this issue Aug 7, 2022 · 1 comment

Comments

@langren1353
Copy link

When use https://sfc.vuejs.org/ sometimes css is not in the output iframe page.
I trace the code and find when code use window.__css__,it is still nothing
this is a problem with es-module-shims witch causes normal script run as module script in twice.

here is a demo:

<html>
<head>
    <meta charset="utf-8">
    <script async="" src="https://unpkg.com/[email protected]/dist/es-module-shims.wasm.js"></script>
</head>
<body>
<script>
    async function start() {
      const scripts = [
        `console.log('script run!!!!!! but run twice')`
      ]
      for(let script of scripts) {
        const scriptNode = document.createElement('script')
        scriptNode.setAttribute('type', 'module')

        scriptNode.innerHTML = script
        document.head.appendChild(scriptNode)
      }
    }
    setTimeout(() => start(), 2000)
</script>
<div>this is a test</div>
<div id="app"></div>
</body>
</html>

you will see two log with script run!!!!!! but run twice

Thus window.__css__ = 'xxxxxxxx' code was covered by window.__css__ = ''(run twice)

@langren1353
Copy link
Author

I don't know how to fix this

Maybe remove es-module-shims.js?or maybe change the original code to make sure curCode in a module or a normal script

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

No branches or pull requests

1 participant