es6-global can't resolve external node modules as URI
build this code:
external createSandbox : unit => Js.t {..} = "create" [@@bs.scope "sandbox"] [@@bs.module "sinon"];
expect to genearte:
import * as Sinon from "../../node_modules/sinon";
but actual to generate:
/*
wrong:
import * as Sinon from "sinon";
*/
/* fixed */
import * as Sinon from "../../node_modules/sinon/dist/sinon.js"
refer to #1193:
how to know the path of external JS library, currently we leave it as it Implementation details: we might need have a global view of dependencies and pass a package map unlike current implementation which did lots of path calculation
can @bobzhang fix it?
what's your motivation here?
note your third party js dependency probably does not work with browser out of box (even with es6 module support). for example, in browser, you have to write from "./xxx.js" instead of from "./xxx"
I want to use es6 module in chrome, so that i don't need to rollup the bundle before run in chrome.
yes, the "expect to generate" is wrong here, the actual expect is like:
import * as Sinon from "../../node_modules/sinon/dist/sinon.js";
/* get "dist/sinon.js" path from sinon->pacakge.json->main field */
👍 I'd like to see this too. Right now I have to make some nasty manual file transformations in order to get my local environment to work properly.
Still not solved? I'm having this issue when using Reason+React, and importing React through CDN.
+1 - It would be nice to be able to work on a React project without dev-time bundling.
I was working on a small project in the browser with es6-global and it was excellent until I added React. I ended up changing that setting to es6 and now use ESBuild to do the bundling, like this:
yarn run esbuild src/ui/EntryPoint.js --bundle --outfile=build/out.js
(Maybe someone will find this helpful)
EDIT: I have since removed ESBuild in favor of import maps in my index.html:
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@17",
"react-dom": "https://esm.sh/react-dom@17"
}
}
</script>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.