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

Browser Global variable scope issues #52

Closed
1 task done
Apidcloud opened this issue Mar 9, 2019 · 0 comments · Fixed by #57
Closed
1 task done

Browser Global variable scope issues #52

Apidcloud opened this issue Mar 9, 2019 · 0 comments · Fixed by #57
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested

Comments

@Apidcloud
Copy link
Member

Apidcloud commented Mar 9, 2019

TLDR

We have issues with the global variable SC because we have now multiple packages which do not reuse the scope. We might want to see ES modules, as they are already supported in browsers through <script type="module"></script>.
I think that way we can use multiple packages in the browser. Will test soon.

  • Test the above assumption.
    • Result: doesn't really work. See below why. What I tested is available in the test/esModules branch. We might need it later.

Edit: It's not so simple after all. UMD is not compatible with ES Modules just yet (see umdjs/umd#124 and umdjs/umd#134), so it ends up breaking anyway.

Long version

Since this is now a monorepo and we have multiple packages, importing them with the script tag within html will replace the global variable SC every time. See demos folder for example.

There is an option that I don't like that much though, and I would rather find an alternative solution:

  • creating a separate build to bundle every package into 1 file. Sort of what we had before. And we would still use the separate packages for every other scenario.

I don't like it because the individual bundles are already UMD, which in turn is compatible with browsers too. Having to do a single separate build, also UMD, seems like a waste.

Not sure if this is really urgent for now since it's only affecting the browser.

We should also take a look into ES modules: https://flaviocopes.com/es-modules/ because it might turn out to not be an issue at all when using them!

More info on ES modules:
https://www.ecma-international.org/ecma-262/6.0/#sec-modules
https://babeljs.io/docs/en/babel-preset-env#targetsesmodules

@Apidcloud Apidcloud added bug Something isn't working help wanted Extra attention is needed question Further information is requested labels Mar 9, 2019
@Apidcloud Apidcloud self-assigned this Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested
Projects
None yet
1 participant