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

Scripts in imported HTML files are not executed #9963

Open
foxt opened this issue Sep 26, 2024 · 0 comments
Open

Scripts in imported HTML files are not executed #9963

foxt opened this issue Sep 26, 2024 · 0 comments

Comments

@foxt
Copy link

foxt commented Sep 26, 2024

🐛 bug report

If you import a .html file from a JS file (either by bundle-text: or new URL() any scripts in the page do not execute.

🤔 Expected Behavior

Scripts in the page execute

😯 Current Behavior

Scripts do not execute.

💁 Possible Solution

The parameters passed to the Parcel runtime entry function are:

[
    /*modules*/ {
        '(hmrModule)': [
            function (require,module,exports) { /* */ }, 
            {}
        ],
        '(mainModule)': [
            function (require,module,exports) { alert(1) }, 
            {}
        ]
    },
    /*entry*/ ['(hmrModule)'],
    /*mainEntry*/ null,
    /*parcelRequireName*/ 'parcelRequiree764'
]

But if you compare this to the entry-point HTML file, where the runtime entry function is called with:

[
    /*modules*/ { /* */ },
    /*entry*/ ['(hmrModule)', '(mainModule)'],
    /*mainEntry*/ '(mainModule)',
    /*parcelRequireName*/ 'parcelRequiree764'
]

It seems as if the main module is missing from the entry and mainEntry parameters. This might be the cause of the issue?

🔦 Context

💻 Code Sample

test.html

<head></head>
<body></body>

<script type="module">
     alert(1)
</script>

and then in another JS file

const myHtml = `
    <a href="${new URL('./test.html', import.meta.url).href}">Test</a>
`

🌍 Your Environment

Software Version(s)
Parcel v2.12.0
Node v22.2.0
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