Skip to content

Commit

Permalink
Add default npm importmap to project root
Browse files Browse the repository at this point in the history
  • Loading branch information
hrajchert committed Sep 18, 2023
1 parent bf17a9c commit 434d69b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 12 deletions.
13 changes: 13 additions & 0 deletions doc/howToDevelop.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,16 @@ And in a separate project you can install the tarballs using a file url when dec

TODO [[Publish pre-check]] Local map and this pack instructions
TODO instructions on how to manually publish
In order to check that the export/import mechanism works on the browser using import maps you can:

1. Create a testing branch in a fork of the repo
1. Clean and build the project `npm run clean && npm run build`
1. Remove `dist` from `.gitignore`
1. Commit the `dist` folders of the different packages
1. Get the full git hash of the commit using `git rev-parse HEAD`
1. Publish the branch in your fork
1. Modify `rollup/config.mjs` and set the correct `owner` and `version` when we build the import map for jsdelivr-gh.
1. Rebuild the project `npm run build`
1. Modify the html in the `pocs` folder to use `/dist/jsdelivr-gh-importmap.js`
1. From the root folder run `npx http-server --port 1337 -c-1 -o ./`
1. Verify that each poc example works properly.
38 changes: 38 additions & 0 deletions jsdelivr-npm-importmap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const importMap = {
"imports": {
"@marlowe.io/adapter": "https:/cdn.jsdelivr.net/npm/marlowe.io/adapter@0.2.0-alpha/dist/bundled/esm/adapter.js",
"@marlowe.io/adapter/codec": "https:/cdn.jsdelivr.net/npm/marlowe.io/adapter@0.2.0-alpha/dist/bundled/esm/codec.js",
"@marlowe.io/adapter/file": "https:/cdn.jsdelivr.net/npm/marlowe.io/adapter@0.2.0-alpha/dist/bundled/esm/file.js",
"@marlowe.io/adapter/fp-ts": "https:/cdn.jsdelivr.net/npm/marlowe.io/adapter@0.2.0-alpha/dist/bundled/esm/fp-ts.js",
"@marlowe.io/adapter/http": "https:/cdn.jsdelivr.net/npm/marlowe.io/adapter@0.2.0-alpha/dist/bundled/esm/http.js",
"@marlowe.io/adapter/time": "https:/cdn.jsdelivr.net/npm/marlowe.io/adapter@0.2.0-alpha/dist/bundled/esm/time.js",
"@marlowe.io/language-core-v1": "https:/cdn.jsdelivr.net/npm/marlowe.io/language-core-v1@0.2.0-alpha/dist/bundled/esm/language-core-v1.js",
"@marlowe.io/language-core-v1/environment": "https:/cdn.jsdelivr.net/npm/marlowe.io/language-core-v1@0.2.0-alpha/dist/bundled/esm/environment.js",
"@marlowe.io/language-core-v1/examples": "https:/cdn.jsdelivr.net/npm/marlowe.io/language-core-v1@0.2.0-alpha/dist/bundled/esm/examples.js",
"@marlowe.io/language-core-v1/next": "https:/cdn.jsdelivr.net/npm/marlowe.io/language-core-v1@0.2.0-alpha/dist/bundled/esm/next.js",
"@marlowe.io/language-core-v1/state": "https:/cdn.jsdelivr.net/npm/marlowe.io/language-core-v1@0.2.0-alpha/dist/bundled/esm/state.js",
"@marlowe.io/language-core-v1/token": "https:/cdn.jsdelivr.net/npm/marlowe.io/language-core-v1@0.2.0-alpha/dist/bundled/esm/token.js",
"@marlowe.io/language-core-v1/tokenValue": "https:/cdn.jsdelivr.net/npm/marlowe.io/language-core-v1@0.2.0-alpha/dist/bundled/esm/tokenValue.js",
"@marlowe.io/language-core-v1/version": "https:/cdn.jsdelivr.net/npm/marlowe.io/language-core-v1@0.2.0-alpha/dist/bundled/esm/version.js",
"@marlowe.io/token-metadata-client": "https:/cdn.jsdelivr.net/npm/marlowe.io/token-metadata-client@0.2.0-alpha/dist/bundled/esm/token-metadata-client.js",
"@marlowe.io/wallet": "https:/cdn.jsdelivr.net/npm/marlowe.io/wallet@0.2.0-alpha/dist/bundled/esm/wallet.js",
"@marlowe.io/wallet/api": "https:/cdn.jsdelivr.net/npm/marlowe.io/wallet@0.2.0-alpha/dist/bundled/esm/api.js",
"@marlowe.io/wallet/browser": "https:/cdn.jsdelivr.net/npm/marlowe.io/wallet@0.2.0-alpha/dist/bundled/esm/browser.js",
"@marlowe.io/wallet/nodejs": "https:/cdn.jsdelivr.net/npm/marlowe.io/wallet@0.2.0-alpha/dist/bundled/esm/nodejs.js",
"@marlowe.io/runtime-rest-client": "https:/cdn.jsdelivr.net/npm/marlowe.io/runtime-rest-client@0.2.0-alpha/dist/bundled/esm/runtime-rest-client.js",
"@marlowe.io/runtime-rest-client/transaction": "https:/cdn.jsdelivr.net/npm/marlowe.io/runtime-rest-client@0.2.0-alpha/dist/bundled/esm/transaction.js",
"@marlowe.io/runtime-rest-client/withdrawal": "https:/cdn.jsdelivr.net/npm/marlowe.io/runtime-rest-client@0.2.0-alpha/dist/bundled/esm/withdrawal.js",
"@marlowe.io/runtime-core": "https:/cdn.jsdelivr.net/npm/marlowe.io/runtime-core@0.2.0-alpha/dist/bundled/esm/runtime-core.js",
"@marlowe.io/runtime-lifecycle": "https:/cdn.jsdelivr.net/npm/marlowe.io/runtime-lifecycle@0.2.0-alpha/dist/bundled/esm/runtime-lifecycle.js",
"@marlowe.io/runtime-lifecycle/api": "https:/cdn.jsdelivr.net/npm/marlowe.io/runtime-lifecycle@0.2.0-alpha/dist/bundled/esm/api.js",
"@marlowe.io/runtime-lifecycle/browser": "https:/cdn.jsdelivr.net/npm/marlowe.io/runtime-lifecycle@0.2.0-alpha/dist/bundled/esm/browser.js",
"@marlowe.io/runtime-lifecycle/nodejs": "https:/cdn.jsdelivr.net/npm/marlowe.io/runtime-lifecycle@0.2.0-alpha/dist/bundled/esm/nodejs.js",
"@marlowe.io/runtime-lifecycle/overRestAPI": "https:/cdn.jsdelivr.net/npm/marlowe.io/runtime-lifecycle@0.2.0-alpha/dist/bundled/esm/overRestAPI.js",
"@marlowe.io/runtime-lifecycle/tx": "https:/cdn.jsdelivr.net/npm/marlowe.io/runtime-lifecycle@0.2.0-alpha/dist/bundled/esm/tx.js",
"lucid-cardano": "https://unpkg.com/lucid-cardano@0.10.7/web/mod.js"
}
};
const im = document.createElement('script');
im.type = 'importmap';
im.textContent = JSON.stringify(importMap);
document.currentScript.after(im);
14 changes: 4 additions & 10 deletions packages/wallet/Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @marlowe.io/wallet
# Description

This package provides functionality to work with a CIP30 wallet.

Expand All @@ -11,21 +11,15 @@ It has the following modules:

## Getting started

The `@marlowe.io/wallet` package is [packaged as an ESM module](http://TODO-link-to-the-doc-file-in-gh.com) and requires the following peer dependencies:

### Browser

The `@marlowe.io/wallet` package is released as an [ESM module](http://TODO-link-to-the-doc-file-in-gh.com) and requires the following peer dependencies:

- [lucid-cardano](https://github.com/spacebudz/lucid): a library that provides a browser implementation of the CIP30 specification. Will likely be replaced by [Cardano SDK](https://github.com/input-output-hk/cardano-js-sdk/tree/master/packages/wallet) in the future (once they offer CBOR capabilities that replace the need for the WASM library).

```html
<script type="importmap">
{
"imports": {
"@marlowe.io/wallet": "/dist/wallet/esm/index.js",
"lucid-cardano": "https://unpkg.com/lucid-cardano@0.10.7/web/mod.js"
}
}
</script>
<script src="https://cdn.jsdelivr.net/gh/input-output-hk/marlowe-ts-sdk/jsdelivr-npm-importmap.js">
<script type="module">
import { createBrowserWallet, getAvailableWallets } from "@marlowe.io/wallet";
Expand Down
4 changes: 2 additions & 2 deletions rollup/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ const projectRoot = path.join(
);

await buildImportMapScript(packagesInfo, {type: "local"}, path.join(projectRoot, "dist"));
await buildImportMapScript(packagesInfo, {type: "jsdelivr-npm", version: "0.2.0-alpha"}, path.join(projectRoot, "dist"));
await buildImportMapScript(packagesInfo, {type: "jsdelivr-npm", version: "0.2.0-alpha"}, projectRoot);
// This is for testing purposes only, search [[Publish pre-check]]
await buildImportMapScript(packagesInfo, {type: "jsdelivr-gh", owner: "hrajchert", version: "081ea368e70b3126a71e076ae11c713b5163aefb"}, path.join(projectRoot, "dist"));
await buildImportMapScript(packagesInfo, {type: "jsdelivr-gh", owner: "hrajchert", version: "126dfc25b8ae524f5bad1707fd20b4568be3f6ef"}, path.join(projectRoot, "dist"));


const config = [
Expand Down

0 comments on commit 434d69b

Please sign in to comment.