Parcel: Script tags are not executed in the global scope and do not work after bundling

Created on 4 Jun 2018  路  7Comments  路  Source: parcel-bundler/parcel

馃悰 bug report

Included vanilla javascript scripts are not executed in the global scope the way they are in a non-bundled, statically-served site.

馃帥 Configuration (.babelrc, package.json, cli command)

No configuration.

Bundling a vanilla, static website.

馃 Expected Behavior

A vanilla bundled website should behave the same before and after it's bundled.

馃槸 Current Behavior

includedScript.js

var testVariable = 1000;

index.html

<head><html>
    <script src="./includedScript.js" />
    <script>
        // Prints "1000" in static server
        // Undefined variable error when bundled
        console.log(testVariable);
    </script>
</html><body>
</body></html>

馃拋 Possible Solution

Execute normal included script tags in the global scope instead of scoping them. Required or otherwise imported scripts can still be scoped accordingly.

馃敠 Context

Trying to bundle a static website for production and use older libraries that rely on global scope.

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.8.1
| Node | 8.6.0
| npm | 5.3.0
| Operating System | Windows 10

Bug

Most helpful comment

same problem here. Any fix?

All 7 comments

Will be fixed in #1456

I still occur this issue in version: 1.10.3

I was also seeing that this was an issue.

same problem here. Any fix?

I still occur this issue in version: 1.10.3

What my solution is :
add --no-minify in terminal command.

then my html works correctly .

I was also seeing that this was an issue.

What my solution is :
add --no-minify in terminal command.

then my html works correctly .

same problem here. Any fix?

What my solution is :
add --no-minify in terminal command.

then my html works correctly .

Was this page helpful?
0 / 5 - 0 ratings