jspm / project

Roadmap and management repo for the jspm project
161 stars 8 forks source link

Resource loading from an organization (@org/pkg) module results in a shortened url #82

Closed arlac77 closed 3 years ago

arlac77 commented 4 years ago

importing @symatem/core

with fetch inside

fetch(new URL('./blake2.wasm', import.meta.url))

results in the following short URL ( without '/core' npm module name of the @symatem org) https://jspm.dev/npm:@symatem/blake2.wasm

but expected was https://jspm.dev/npm:@symatem/core/blake2.wasm

package.json

{
  "name": "@symatem/core",
  "exports": {
        ".": "./src/SymatemJS.mjs",
        "./blake2.wasm": "./src/blake2.wasm",
        "./backend.wasm": "./src/backend.wasm"
    }
}

How to prevent the removal of '/core' ?

Additionally the is no resource at

https://jspm.dev/npm:@symatem/core/blake2.wasm

only at

https://jspm.dev/npm:@symatem/core@0.0.6/src/blake2.wasm

guybedford commented 4 years ago

This is because the entry point ./src/SymatemJS.mjs is inlined into the entry file npm:@symatem/core@0.0.6 and is thus at a "lower level". Effectively the problem is that the import.meta.url reference is not being adjusted with the file moving location.

This is actually a not-yet-supported feature and is planned and tracking in https://github.com/jspm/project/issues/69.

If this feature is important to you another way to speed things up is to sponsor the project, but I will get to it either way, it's just a problem of prioritization on the project.

guybedford commented 3 years ago

Closing as #69 is still tracking this, there are just other priorities right now still.