Skip to content
This repository has been archived by the owner on Jan 23, 2020. It is now read-only.

URL Design #3

Open
digitalsadhu opened this issue Aug 15, 2019 · 4 comments
Open

URL Design #3

digitalsadhu opened this issue Aug 15, 2019 · 4 comments

Comments

@digitalsadhu
Copy link
Member

digitalsadhu commented Aug 15, 2019

In the prototypes made so far, a URL structure has been loosely determined with some but not a lot of thought. The following lays out the URLs that are currently in use in the prototype.

1. A global published module's immutable URLs

http://:assetServerUrl:port/:org/pkg/:pkgName/:version/index.js
http://:assetServerUrl:port/:org/pkg/:pkgName/:version/index.js.map

Where:

  • :org is the name of your organisation
  • :pkgName is the name of the package on npm
  • :version is the version of the package on npm

Example:

http://localhost:4001/finn/pkg/react/16.8.6/index.js
http://localhost:4001/finn/pkg/react/16.8.6/index.js.map

2. A module alias' modifiable URL

http://:assetServerUrl:port/:org/alias/:pkgName/:alias/index.js
http://:assetServerUrl:port/:org/alias/:pkgName/:alias/index.js.map

Where:

  • :org is the name of your organisation
  • :pkgName is the name of the package on npm
  • :alias is the alias that you have assigned to the package eg. ^16

Example:

http://localhost:4001/finn/alias/react/^16/index.js
http://localhost:4001/finn/alias/react/^16/index.js.map

3. A modifiable import map file

http://:assetServerUrl:port/:org/map/js

Where:

  • :org is the name of your organisation

Example:

http://localhost:4001/finn/map/js

4. An app's published assets

http://:assetServerUrl:port/:org/bundle/:appName/:version/index.js
http://:assetServerUrl:port>/:org/bundle/:appName/:version/index.js.map

Where:

  • :org is the name of your organisation
  • :appName is the name of your app
  • :version is the version of your assets being published

Example:

http://:assetServerUrl:port/finn/bundle/my-cool-app/1.0.0/index.js
http://:assetServerUrl:port/finn/bundle/my-cool-app/1.0.0/index.js.map
http://:assetServerUrl:port/finn/bundle/my-cool-app/1.0.0/fallback.js // ie11
http://:assetServerUrl:port/finn/bundle/my-cool-app/1.0.0/fallback.js.map
@trygve-lie
Copy link
Collaborator

Great.

Is there any reason why point 4 could not use the same structure as point 1?

I also think we should include the type (esm, iife etc) of the script somehow. Not sure if we want to put that in the pathname or in the filename.

@digitalsadhu
Copy link
Member Author

It could for sure. I think I just chose pkg, alias and bundle as 3 different namespaces to differentiate.

Could drop the pkg and bundle namespaces and make 1. And 4. The same.

@digitalsadhu
Copy link
Member Author

Type should probably be a pathname?

@digitalsadhu
Copy link
Member Author

digitalsadhu commented Aug 16, 2019

How about something like this?

/:org/:name/:version/js/:type/index.js

# /finn/my-app/1.0.0/js/esm/index.js
# /finn/my-app/1.0.0/js/default/index.js
# /finn/my-app/1.0.0/js/cjs/index.js
# /finn/my-app/1.0.0/js/iife/index.js

How do we want to support non esm?
Is this something we care about atm?

I could see iife being a useful way to support older browsers by loading in iife global packages as separate script tags first and then the apps main iife bundle as another script tag or something. Feels to me like we may want to allow for such things but we shouldn't bother implementing initially so in practice the only URL structure we would implement would be /finn/my-app/1.0.0/js/esm/index.js

What about fallbacks? Could they be part of this URL structure? instead of /../fallback/../ could they be /../iife/../ ?

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

No branches or pull requests

2 participants