Errors importing as an ES module from unpkg
See original GitHub issueI have been trying to import navi directly from unpkg and have come across a few errors:
- If you request
https://unpkg.com/navi@0.11.6?module
then this error appears:
Apparently this is related to webpack https://github.com/webpack/webpack/issues/8838
- If you specify the exact file
https://unpkg.com/navi@0.11.6/dist/es/index.js
then the above error disappears but then this error appears:
Apparently this is to do with navi having history
as an optional dependency (for interoperability with react-router). Solving this issue is likely to negate issue 1.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
es-module-loader/README.md - UNPKG
The CDN for es-module-loader. ... 6, Supports the [loader import and registry ... Errors are cached in the registry, until the `delete` API...
Read more >mwc-drawer raises error when used from unpkg.com ... - GitHub
I would like to use the mwc-drawer and import the module from unpkg.com. But it fails with the error Package blocking-elements@0.1.0 does ...
Read more >ES6 modules via script tag has the error "The requested ...
It seems that the code you import from the URL has been transpiled, meaning that it no longer works with import and export...
Read more >Everything You Need to Know About JavaScript Import Maps
With this mapping, any modules in the /static/js path will use the https://unpkg.com/lodash-es@3.10.1/ URL when referring to the lodash/ ...
Read more >rollup.js
In addition to enabling the use of ES modules, Rollup also statically analyzes the code you are importing, and will exclude anything that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re welcome 😄
I see - yeah I was using
?module
. You’re right that it’d probably work if you just used the raw file, although now that I’m deprecatingnavigation.history
, I think I might just wait until the version that removes the dependency completely.A lot of big projects are built around react-router. Allowing integration between the two makes it possible to start writing some routes with Navi in an existing project, without converting the whole thing up front.
As for why Navi relies on history, any router is going to need some way to interact with the browser history, as the raw history API leaves a bit to be desired.
history
also has the advantage of being able to prompt the user when they leave a page though, which is great if you have unedited text and accidentally press “back”.