Comments (11)
@ianterrell Unfortunately this is how the JSPM generator works.
If you want to use the vendored version of a "subpackage export" you have to do this:
bin/importmap pin sortablejs/modular/sortable.core.esm.js
https://jspm.org/docs/jspm-cli/stable/#link
In particular # 4:
Valid package specifiers with subpaths, such as [email protected]/convert-range, in which case the subpath is resolved against the package's exports and the resulting module is linked.
So it seems this is intended behavior. I wonder if importmaps-rails can smooth it over by adding a list of possible exports, or just auto-generating all possible exports for you? Not entirely sure what the answer is.
from importmap-rails.
We're experiencing the same issue — for now I'm using an older version to do the pinning.
Version 2.x still works with libraries pinned directly to the CDN'd version, e.g.:
// config/importmap.rb
pin "sortablejs", to: "https://ga.jspm.io/npm:[email protected]/modular/sortable.esm.js"
To pin, you can downgrade to older version:
# Gemfile
gem "importmap-rails", "~> 1.2"
and then pin:
bundle install
./bin/importmap pin sortablejs
And then reset back to the 2.x version of importmap-rails
if you like.
from importmap-rails.
@ianterrell Interesting. I just did a quick scaffold with sortablejs, but if you have code to share I'd love to take a peek. What you're suggesting may mean that we're only downloading the initial entrypoint, but not vendoring any additional files the import may expect. Hard to know without being able to reproduce the error
from importmap-rails.
@KonnorRogers I think we have a few that are causing that issue, and I must have copied one that wasn't! 😆 imask
is a culprit for us:
❯ ./bin/importmap pin imask
Pinning "imask" to vendor/javascript/imask.js via download from https://ga.jspm.io/npm:[email protected]/esm/index.js
❯ cat config/importmap.rb
# ...
pin "imask" # @7.3.0
❯ git st
# ...
Untracked files:
(use "git add <file>..." to include in what will be committed)
vendor/javascript/imask.js
On request...
❯ tail -100 log/development.log
ActionController::RoutingError (No route matches [GET] "/assets/core/change-details.js"):
ActionController::RoutingError (No route matches [GET] "/assets/core/utils.js"):
ActionController::RoutingError (No route matches [GET] "/assets/masked/base.js"):
ActionController::RoutingError (No route matches [GET] "/assets/masked/date.js"):
# ...
The library as found in the command above:
❯ npx jspm link imask --stdout
{
"imports": {
"imask": "https://ga.jspm.io/npm:[email protected]/esm/index.js"
}
}
❯ curl https://ga.jspm.io/npm:[email protected]/esm/index.js
export{default as InputMask}from"./controls/input.js";
import e from"./core/holder.js";
export{default as HTMLContenteditableMaskElement}from"./controls/html-contenteditable-mask-element.js";
export{default as HTMLInputMaskElement}from"./controls/html-input-mask-element.js";
# ...
Thanks!
from importmap-rails.
@mhenrixon how can I revert to NOT downloading files?
Sadly don't think that importmap-rails 2.x supports using a CDN anymore. 😢
from importmap-rails.
This looks like it might be due to how jspm is returning the dependencies:
npx jspm link @google/model-viewer --stdout
{
"imports": {
"@google/model-viewer": "https://ga.jspm.io/npm:@google/[email protected]/lib/model-viewer.js"
},
"scopes": {
"https://ga.jspm.io/": {
"@lit/reactive-element": "https://ga.jspm.io/npm:@lit/[email protected]/development/reactive-element.js",
"@lit/reactive-element/decorators/": "https://ga.jspm.io/npm:@lit/[email protected]/development/decorators/",
"lit": "https://ga.jspm.io/npm:[email protected]/index.js",
"lit-element/lit-element.js": "https://ga.jspm.io/npm:[email protected]/development/lit-element.js",
"lit-html": "https://ga.jspm.io/npm:[email protected]/development/lit-html.js",
"lit-html/is-server.js": "https://ga.jspm.io/npm:[email protected]/development/is-server.js",
"lit/decorators.js": "https://ga.jspm.io/npm:[email protected]/decorators.js",
"three": "https://ga.jspm.io/npm:[email protected]/build/three.module.js",
"three/": "https://ga.jspm.io/npm:[email protected]/"
}
}
}
from importmap-rails.
I have exactly the same problem; how can I revert to NOT downloading files?
from importmap-rails.
@KonnorRogers Thanks, I'll dive into that. I was likely hitting a related but different issue that I'm working around. My pinning succeeds without issue, but my app receives a million 404s when other related assets are requested, probably from pinning incorrectly to begin with but in a way that seemed to work so far.
from importmap-rails.
Thank you, @ianterrell and @KonnorRogers, for the replication method! TIL how to debug importmaps ❤️
from importmap-rails.
My Rails application template worked doing this with 1.2.3, but now with 2.0.1 does not get all the dependencies for the js libraries pinned.
bin/importmap pin highlight.js
Gives these errors for each language:
Loading module from “http://localhost:3000/lib/languages/scss.js” was blocked because of a disallowed MIME type (“text/html”).
I think because none of the language files have been downloaded.
I get similar errors for popperjs, when pinning bootstrap:
~> bin/importmap pin bootstrap
# importmap.rb
pin "bootstrap" # @5.3.2
pin "@popperjs/core", to: "@popperjs--core.js" # @2.11.8
from importmap-rails.
Discussing improving the download pinning for libraries with dependencies here: #217
But you're also free to just manually point to a CDN. Or use 1.2.x.
from importmap-rails.
Related Issues (20)
- asset_path('es-module-shims.min') does not work in production HOT 1
- files ending in `_index.js` have `index` replaced with an empty string HOT 3
- Why do certain pins disappear in production? HOT 2
- Unpin command causing net error HOT 3
- Confusing message on 'update'
- Unable to unpin HOT 1
- Package works when pinned from JSPM but not when downloaded HOT 2
- Break in iOS 16.2 when upgrading from 1.2.3 to 2.0.1 HOT 4
- turbo:load event not fired anymore in test environment after upgrade from 1.2.3 to 2.0.1 HOT 3
- Feature suggestion: optional `process.env` polyfill
- Multiple importmaps HOT 6
- Importmap update removes pins via http HOT 1
- importmap pin/update removes preload: false
- ga.jspm.io never updates HOT 3
- ./bin/importmap outdated command fails with undefined method `dig' for an instance of String HOT 6
- Add option to `bin/importmap pin URL` to create direct/remote link without downloading
- Option to 're-sync' vendor folder HOT 2
- How to add jquery in importmaps rails 7 HOT 2
- `update` does not update a package even when `outdated` shows the new version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from importmap-rails.