asset-pipe / podium-asset-prototype

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

APv3 Workflow Proposal

digitalsadhu opened this issue · comments

Workflow

Several commands are presented to manipulate global assets and import maps and a publish command is used to publish a podlets assets to the server (making use of globally published assets in the process)

Example: react

  1. create an assets.json metafile and fill in the correct values
  2. publish an esm version of react (16.8.6)
  3. create an appropriate alias for react (^16)
  4. add an entry to the global import map pointing react at ^16
  5. publish the projects own assets

Metafile

The assets.json file.

Each project needs to have an assets.json file to describe various parameters
such as org, app and version. An assets.json file might perhaps look something
like the following:

{
    "organisation": "finn",
    "name": "my-app",
    "version": "2.0.10",
    "server": "<url to asset server>",
    "inputs": {
        "js": "./assets/scripts.js",
        "css": "./assets/styles.css"
    },
}

global publish

  • publish a version of a global dependency

This command takes the name and version of a package on npm, downloads it, creates a bundle of it that is
esm compatible if necessary and then uploads it to the cdn

example:
asset-pipe global publish react@16.8.6

After running the above example, an esm compatible version of react 16.8.6 will be available at
/finn/react/16.8.6

global alias|tag

  • alias|tag a version of a global dependency

This command configures 302 redirects.

example:
asset-pipe global alias react@16.8.6 ^1

After running the above example, /finn/react/^1 will redirect to /finn/react/16.8.6

global map

  • set a specific "bare import" to map to an alias|tag or a specific global depencency version

This command can be used to manipulate the global import map file that is used in the publish command
(described below)

example:
asset-pipe global map react react@^1

After running the command above, all bare import references to react will point to the CDN at <cdn>/finn/react/^1

publish

  • create a bundle, replacing bare imports and publish to the asset server

This command can be used to create a local bundle of assets with bare imports replaced based on a global import map file
and then uploaded to the cdn

example:
asset-pipe publish

After running the command above, the local assets will be available on the cdn at
<cdn>/finn/<app name>/<version>

We also need to handle fallbacks for ex IE11 here. Do we imagine having references to that in the assets.json file or do we base that on convention?

I was thinking convention and that the publish command would just automatically create such a bundle as part of the publish process. We could make it a configurable field with a smart default though?

We should by default create integrity hashes and store these in the asset.json file: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity