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

Import semantics #46

Open
jikkujose opened this issue Mar 16, 2019 · 1 comment
Open

Import semantics #46

jikkujose opened this issue Mar 16, 2019 · 1 comment

Comments

@jikkujose
Copy link

Was looking at the proposals for adding protected name spaces & using stuff like: std: to prefix the standard libraries. Can it be done like so:

Why not consider this as a simple cache rather than something special:

  • Libraries that are white listed gets cached.
  • When a new site requests it, it is served from the cache than downloading it.
  • If not available it will download from npm server or cdn or else from the website itself

With async modules, the preprocessors will start splitting bundles for this.

Advantages:

  1. There is nothing special in importing it, if it isn't available in the cache it gets downloaded. Just ordinary memoization.
  2. It will work in browsers that doesn't support it without any changes
  3. Maintaining whitelist is much simpler, and browsers can differ in opinion what to contain in their list. This will reduce a lot of decision time.
  4. Users can also have control over the whitelist, they can add or delete stuff from it
  5. Browser can offer to add packages based on browsing patterns
  6. This would be a simple "make available offline" if website bundles are added to the whitelist

Disadvantages

  1. Dependency on npm/cdns in a standard solution
@glen-84
Copy link

glen-84 commented Mar 18, 2019

This seems related to #18.

I had a similar idea back in 2009.

I think there are concerns about hash collisions and other related security issues. See #18 for more information.

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

2 participants