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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script tags are not executed in the global scope and do not work after bundling #1491

Closed
gkjohnson opened this issue Jun 4, 2018 · 7 comments

Comments

@gkjohnson
Copy link

gkjohnson commented Jun 4, 2018

馃悰 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
@KeineLimonade
Copy link

Will be fixed in #1456

@zengxp0605
Copy link

I still occur this issue in version: 1.10.3

@gkjohnson
Copy link
Author

I was also seeing that this was an issue.

@whentotrade
Copy link

same problem here. Any fix?

@hanshou101
Copy link

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 .

@hanshou101
Copy link

I was also seeing that this was an issue.

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

then my html works correctly .

@hanshou101
Copy link

same problem here. Any fix?

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

then my html works correctly .

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

No branches or pull requests

7 participants
@gkjohnson @DeMoorJasper @zengxp0605 @KeineLimonade @hanshou101 @whentotrade and others