-
Notifications
You must be signed in to change notification settings - Fork 50
Update to 0.15.0; use ES Module Shims #275
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
Merged
JordanMartinez
merged 35 commits into
purescript:master
from
JordanMartinez:up-to-15-with-esm
Jun 8, 2022
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
00ed3da
Update changelog for last release
JordanMartinez 098fb42
Update purescript deps for 0.15.0; drop cst dep
JordanMartinez 905d54d
Upgrade to latest pkg set; install entire set
JordanMartinez 3880074
Get server code to compile
JordanMartinez 37cf79a
Migrated FFI to ES modules via 'lebab'
JordanMartinez db55540
Removed '"use strict";' in FFI files
JordanMartinez 479619b
Remove redundant import
JordanMartinez 8474470
Update package set; install entire set
JordanMartinez 91f18d1
Update PureScript to 0.15.2
JordanMartinez 84f9908
Use ES Modules Shims for iframe shims
JordanMartinez f436199
Add text to call the `main` function
JordanMartinez 37cdfc8
Update es-module-shims to 1.5.5 (latest)
JordanMartinez 8fa99e8
Move import path update into client
JordanMartinez b15c61b
Revert "Update es-module-shims to 1.5.5 (latest)"
JordanMartinez 7366787
Update readme
JordanMartinez 76a5345
Bundle code via esbuild after remapping imports
JordanMartinez 29c602b
Revert "Bundle code via esbuild after remapping imports"
JordanMartinez 121f928
Use 1.5.5 version of es-module-shims w/ integrity
JordanMartinez 3309843
Set base to fix import remapping issue
JordanMartinez 60730cb
Ensure we only ever run `main()` once
JordanMartinez 37fb6cf
Cleanup imports
JordanMartinez 16aaff7
Fix imports using config url
JordanMartinez e4b49d2
Add serve:production script
JordanMartinez 40f0d95
Add instructions for adding shims to import map
JordanMartinez f671cbc
Doc how to calc integrity hash
JordanMartinez 6b81543
Fix rendering of bullet list
JordanMartinez 27eb703
Remap import paths via base elem set at build time
JordanMartinez f9c30d6
Drop preloaders of shims
JordanMartinez c059482
Cleanup code appending script to body
JordanMartinez a993bc6
Stop infinite `main` invocation when DOM modified
JordanMartinez 9a97914
Update package set to latest; install all packages
JordanMartinez 0fb4edc
Drop workaround; modify `main` el instead
JordanMartinez 0584223
Update base to production; fail CI if not that
JordanMartinez 0369198
Update readme to mention base script
JordanMartinez 1cc3451
Update to latest package set; install entire set
JordanMartinez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,49 @@ | |
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | ||
<meta content="utf-8" http-equiv="encoding"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script src="js/frame.js"></script> | ||
<!-- Do not edit the base element's 'href' manually. Use the 'base:dev' or 'base:production' script --> | ||
<base href="/output/ignored/"> | ||
<script> | ||
window.esmsInitOptions = { | ||
// -- Hooks -- | ||
// Module load error | ||
onerror: (e) => { | ||
console.log("Error while loading module: "); | ||
console.log(e); | ||
throw e; | ||
}, | ||
}; | ||
</script> | ||
<!-- | ||
JSPM Generator Import Map | ||
Edit URL: https://generator.jspm.io/#Y2NnYGCzD80rySzJSU1hSMpM183MK0lNTy1yMNQz0zM1ZEhJTc7MTczRyyp2MDTQM9YzZChKTUwu0U3Jz3UwNNMzxCqiX5xaVJZaBJGAKystzUxxsACaYQQAoBlP83cA | ||
--> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"big-integer": "https://ga.jspm.io/npm:[email protected]/BigInteger.js", | ||
"decimal.js": "https://ga.jspm.io/npm:[email protected]/decimal.js", | ||
"react": "https://ga.jspm.io/npm:[email protected]/index.js", | ||
"react-dom": "https://ga.jspm.io/npm:[email protected]/index.js", | ||
"react-dom/server": "https://ga.jspm.io/npm:[email protected]/server.browser.js", | ||
"uuid": "https://ga.jspm.io/npm:[email protected]/dist/esm-browser/index.js" | ||
}, | ||
"scopes": { | ||
"https://ga.jspm.io/": { | ||
"object-assign": "https://ga.jspm.io/npm:[email protected]/index.js", | ||
"react": "https://ga.jspm.io/npm:[email protected]/index.js", | ||
"scheduler": "https://ga.jspm.io/npm:[email protected]/index.js" | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<!-- ES Module Shims: Import maps polyfill for modules browsers without import maps support (all except Chrome 89+) --> | ||
<script async src="https://ga.jspm.io/npm:[email protected]/dist/es-module-shims.js" integrity="sha384-Zt+0efULC2q2dftjz0uNzXeTpPVuSLLekXQv9HoRuigkAyLPaUFvPVpYYhu2Xc/t" crossorigin="anonymous"></script> | ||
|
||
<script src="/js/frame.js"></script> | ||
</head> | ||
<body> | ||
<main id="main"></main> | ||
<main id="main"></main> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env node | ||
|
||
import path from "path"; | ||
import fs from "fs"; | ||
import process from "process"; | ||
|
||
const filePath = path.join("public", "frame.html"); | ||
|
||
// PureScript generates JS with the following import lines: | ||
// `import * as Data_Foo from "../Data.Foo/index.js" | ||
// To remap `../Data.Foo/index.js` to `output/Data.Foo/index.js` | ||
// we append `/ignored/`. | ||
// | ||
// This: `/output/ignored/../Data.Foo/index.js` | ||
// becomes: `/output/Data.Foo/index.js` | ||
const prodPath = "/output/ignored/" | ||
const devPath = "/js/output/ignored/" | ||
|
||
const environment = process.argv[2] || "dev"; | ||
const baseHref = environment === "prod" ? prodPath : devPath; | ||
|
||
const frameHtml = fs.readFileSync(filePath, "utf-8"); | ||
const newHtml = frameHtml | ||
.split("\n") | ||
.map((line) => line.replace(/^( *<base href=")[^"]*(".+)$/, `$1${baseHref}$2`)) | ||
.join("\n"); | ||
|
||
fs.writeFileSync(filePath, newHtml); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have to rewrite the file in place, I'm not sure this is the best way to do this. Will this dirty the source tree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also curious how this works with the actual prod deployment of the UI. I'm not fully aware of all that goes into that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it would dirty the source tree.
The client is built in the
ci.yml
file by using NPM scripts before packaging up the results. When we deploy the code, the server downloads theclient.tar.gz
, unpacks it, and then runs it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should this issue be resolved? Do we create 2 versions of the
frame.html
file, one withbase
set to one and another withbase
set to something else?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a check in CI to fail the build if the
base
element does not refer to the production path. One can usenpm run base:dev
to test out their code in development and then runnpm run base:production
before committing the final results. This ensures the following:frame.html
isn't duplicated, so there's only one place to update the import mapsI believe that resolves your final issue with this PR.