question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Errors importing as an ES module from unpkg

See original GitHub issue

I have been trying to import navi directly from unpkg and have come across a few errors:

  1. If you request https://unpkg.com/navi@0.11.6?module then this error appears:
screen shot 2019-03-04 at 15 21 31

Apparently this is related to webpack https://github.com/webpack/webpack/issues/8838

  1. 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:
screen shot 2019-03-04 at 15 28 22

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:closed
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
jamesknelsoncommented, Mar 15, 2019

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 deprecating navigation.history, I think I might just wait until the version that removes the dependency completely.

1reaction
jamesknelsoncommented, Mar 4, 2019

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”.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found