René's URL Explorer Experiment


Title: Proposal: Load foreign code with ES Module Shims and import maps · Issue #263 · purescript/trypurescript · GitHub

Open Graph Title: Proposal: Load foreign code with ES Module Shims and import maps · Issue #263 · purescript/trypurescript

X Title: Proposal: Load foreign code with ES Module Shims and import maps · Issue #263 · purescript/trypurescript

Description: Try PureScript is going to have to be reworked when the PureScript compiler switches from CommonJS to ES modules for foreign code. This issue details a proposal for how to handle this rewrite. Current Implementation We currently parse th...

Open Graph Description: Try PureScript is going to have to be reworked when the PureScript compiler switches from CommonJS to ES modules for foreign code. This issue details a proposal for how to handle this rewrite. Curr...

X Description: Try PureScript is going to have to be reworked when the PureScript compiler switches from CommonJS to ES modules for foreign code. This issue details a proposal for how to handle this rewrite. Curr...

Opengraph URL: https://github.com/purescript/trypurescript/issues/263

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: Load foreign code with ES Module Shims and import maps","articleBody":"Try PureScript is going to have to be reworked when the PureScript compiler [switches from CommonJS to ES modules](https://github.com/purescript/purescript/pull/3791) for foreign code. This issue details a proposal for how to handle this rewrite.\r\n\r\n### Current Implementation\r\n\r\nWe currently parse through the generated JavaScript on Try PureScript to discover all dependencies present via `require()` statements. For every dependency we find we do one of:\r\n\r\n1. Load the JS from `compile.purescript.org` (for example, [`Data.EuclidianRing/foreign.js`](https://compile.purescript.org/output/Data.EuclideanRing/foreign.js))\r\n2. Look up its URL from the [Shim.purs](https://github.com/purescript/trypurescript/blob/master/client/src/Try/Shim.purs) file which lists CDN locations for some common FFI libraries like `react`, and then load the contents\r\n\r\nOnce we know what dependencies to load, we take their contents and insert them into the code iframe. Finally, we load their contents via the [`evalSources` function in `frame.js`](https://github.com/purescript/trypurescript/blob/af70d48e3d500ab6909e782b7ac50f982b6948e2/client/public/js/frame.js#L2-L28).\r\n\r\n### Issues\r\n\r\nThis code is no longer going to work. PureScript 0.15 will only work with ES modules, so the code in `Shim.purs`, `Loader.purs`, and `frame.js` will all need to be updated to work with ES modules instead of CommonJS modules -- in other words, there is no more `require` or `module.exports`; instead, there's `import` and `export`.\r\n\r\nI also don't think we can instantiate the code the same way we do now, which I _believe_ happens here:\r\n\r\nhttps://github.com/purescript/trypurescript/blob/53a82a636802aad4007a0a6cbee9bc7dfdd1be4b/client/public/js/frame.js#L25\r\n\r\nFinally, if we swap all the way over to ES modules, we lose all Internet Explorer support, which we have historically not wanted to lose.\r\n\r\n### Proposal: SystemJS\r\n\r\nWe're clearly going to have to rewrite how we handle foreign code in Try PureScript. After a brief discussion with @natefaubion on the PureScript chat I would like to propose that we use two technologies:\r\n\r\n1. [SystemJS](https://github.com/systemjs/systemjs), which [covers IE11](https://github.com/systemjs/systemjs#ie11-support)\r\n2. [Import maps](https://wicg.github.io/import-maps), which are [supported in SystemJS](https://github.com/systemjs/systemjs#import-maps), including [for IE11](https://github.com/systemjs/systemjs#note-on-import-maps-support-in-ie11)\r\n\r\nThe [SystemJS documentation on import maps](https://github.com/systemjs/systemjs/blob/main/docs/import-maps.md) does a good job of explaining how we can use this tool to replace our existing shim + loader + frame.js setup. If I'm reading correctly, we'd strip out almost everything and move the contents of `Shim.purs` into an import map. We'd rely on SystemJS for everything else.","author":{"url":"https://github.com/thomashoneyman","@type":"Person","name":"thomashoneyman"},"datePublished":"2022-01-18T03:58:31Z","url":"https://github.com/purescript/trypurescript/issues/263"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b8b72566-2eee-6f2f-a28c-ca33a14127f9
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAAA8:23880A:F17784:14D1BCD:6AFBF560
html-safe-noncefc625b2c478b3449578c5b1e5841f3ad145e6f8fd01fcccdaa3a6096b3f2dd58
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUE4OjIzODgwQTpGMTc3ODQ6MTREMUJDRDo2QUZCRjU2MCIsInZpc2l0b3JfaWQiOiIzMDM2NjUzNjA5MzQ2MTM1MzkyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac40e7f96e71e4531e222fc7d7c6fc101a1efadbdff30e4d01b1f9f94f4fa0cdc5
hovercard-subject-tagissue:1106449877
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/purescript/trypurescript/263/issue_layout
twitter:imagehttps://opengraph.githubassets.com/dfe70a322492d9c573d20c9ee6dc563bc5383e98995e0ce1f8a203192e3af28d/purescript/trypurescript/issues/263
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/dfe70a322492d9c573d20c9ee6dc563bc5383e98995e0ce1f8a203192e3af28d/purescript/trypurescript/issues/263
og:image:altTry PureScript is going to have to be reworked when the PureScript compiler switches from CommonJS to ES modules for foreign code. This issue details a proposal for how to handle this rewrite. Curr...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamethomashoneyman
hostnamegithub.com
expected-hostnamegithub.com
Nonefa74413a1d84dac536fcca0740780bcbd3207bafec0e51873b73ff8e8cca032f
turbo-cache-controlno-preview
go-importgithub.com/purescript/trypurescript git https://github.com/purescript/trypurescript.git
octolytics-dimension-user_id6556677
octolytics-dimension-user_loginpurescript
octolytics-dimension-repository_id14093432
octolytics-dimension-repository_nwopurescript/trypurescript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id14093432
octolytics-dimension-repository_network_root_nwopurescript/trypurescript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseb3b5633a74535d9c23385512d534c66c8fde1907
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/purescript/trypurescript/issues/263#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpurescript%2Ftrypurescript%2Fissues%2F263
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpurescript%2Ftrypurescript%2Fissues%2F263
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=purescript%2Ftrypurescript
Reloadhttps://github.com/purescript/trypurescript/issues/263
Reloadhttps://github.com/purescript/trypurescript/issues/263
Reloadhttps://github.com/purescript/trypurescript/issues/263
purescripthttps://github.com/purescript
trypurescripthttps://github.com/purescript/trypurescript
Codehttps://github.com/purescript/trypurescript
Issues23 (23)https://github.com/purescript/trypurescript/issues
Pull requests5 (5)https://github.com/purescript/trypurescript/pulls
Actionshttps://github.com/purescript/trypurescript/actions
Security and qualityhttps://github.com/purescript/trypurescript/security
Insightshttps://github.com/purescript/trypurescript/pulse
https://github.com/purescript/trypurescript
New issuehttps://github.com/login?return_to=https://github.com/purescript/trypurescript/issues/263
New issuehttps://github.com/login?return_to=https://github.com/purescript/trypurescript/issues/263
#275https://github.com/purescript/trypurescript/pull/275
Proposal: Load foreign code with ES Module Shims and import mapshttps://github.com/purescript/trypurescript/issues/263#top
#275https://github.com/purescript/trypurescript/pull/275
https://github.com/thomashoneyman
thomashoneymanhttps://github.com/thomashoneyman
on Jan 18, 2022https://github.com/purescript/trypurescript/issues/263#issue-1106449877
switches from CommonJS to ES moduleshttps://github.com/purescript/purescript/pull/3791
Data.EuclidianRing/foreign.jshttps://compile.purescript.org/output/Data.EuclideanRing/foreign.js
Shim.purshttps://github.com/purescript/trypurescript/blob/master/client/src/Try/Shim.purs
evalSources function in frame.jshttps://github.com/purescript/trypurescript/blob/af70d48e3d500ab6909e782b7ac50f982b6948e2/client/public/js/frame.js#L2-L28
trypurescript/client/public/js/frame.jshttps://github.com/purescript/trypurescript/blob/53a82a636802aad4007a0a6cbee9bc7dfdd1be4b/client/public/js/frame.js#L25
53a82a6https://github.com/purescript/trypurescript/commit/53a82a636802aad4007a0a6cbee9bc7dfdd1be4b
@natefaubionhttps://github.com/natefaubion
SystemJShttps://github.com/systemjs/systemjs
covers IE11https://github.com/systemjs/systemjs#ie11-support
Import mapshttps://wicg.github.io/import-maps
supported in SystemJShttps://github.com/systemjs/systemjs#import-maps
for IE11https://github.com/systemjs/systemjs#note-on-import-maps-support-in-ie11
SystemJS documentation on import mapshttps://github.com/systemjs/systemjs/blob/main/docs/import-maps.md
https://github.com/JordanMartinez
JordanMartinezhttps://github.com/JordanMartinez
on May 11, 2022https://github.com/purescript/trypurescript/issues/263#issuecomment-1123510239
Can't click links in the iframe #137https://github.com/purescript/trypurescript/issues/137
Allow gist navigation #140https://github.com/purescript/trypurescript/pull/140
react-hello-worldhttps://github.com/systemjs/systemjs-examples/tree/master/loading-code/react-hello-world
Per their docshttps://github.com/systemjs/systemjs#loading-a-systemregister-module
https://github.com/JordanMartinez
JordanMartinezhttps://github.com/JordanMartinez
on May 11, 2022https://github.com/purescript/trypurescript/issues/263#issuecomment-1123713718
https://github.com/natefaubion
natefaubionhttps://github.com/natefaubion
on May 11, 2022https://github.com/purescript/trypurescript/issues/263#issuecomment-1123759874
https://github.com/guybedford/es-module-shimshttps://github.com/guybedford/es-module-shims
https://github.com/JordanMartinez
JordanMartinezhttps://github.com/JordanMartinez
on May 14, 2022https://github.com/purescript/trypurescript/issues/263#issuecomment-1126736820
https://github.com/JordanMartinez/use-emshttps://github.com/JordanMartinez/use-ems
https://jspm.org/https://jspm.org/
@mikesolhttps://github.com/mikesol
https://github.com/mikesol
mikesolhttps://github.com/mikesol
on May 14, 2022https://github.com/purescript/trypurescript/issues/263#issuecomment-1126739122
JordanMartinezhttps://github.com/JordanMartinez
on May 18, 2022https://github.com/purescript/trypurescript/issues/263#event-6636567361
JordanMartinezhttps://github.com/JordanMartinez
completedhttps://github.com/purescript/trypurescript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#275https://github.com/purescript/trypurescript/pull/275
on Jun 8, 2022https://github.com/purescript/trypurescript/issues/263#event-6772390258
Sign up for freehttps://github.com/signup?return_to=https://github.com/purescript/trypurescript/issues/263
Sign in to commenthttps://github.com/login?return_to=https://github.com/purescript/trypurescript/issues/263
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.