Skip to content

Pinning dependencies with internal package imports fails #319

@searls

Description

@searls

I've tried a few times to pin mediabunny but each time has resulted in a non-working configuration.

$ bin/importmap pin mediabunny
Pinning "mediabunny" to vendor/javascript/mediabunny.js via download from https://ga.jspm.io/npm:[email protected]/dist/modules/src/index.js
Pinning "#dist/modules/src/node.js" to vendor/javascript/#dist/modules/src/node.js.js via download from https://ga.jspm.io/npm:@jspm/[email protected]/nodelibs/@empty.js

Will result in this importmap.rb:

# config/importmap.rb
pin "mediabunny" # @1.24.2
pin "#dist/modules/src/node.js", to: "#dist--modules--src--node.js.js" # @2.1.0

And these files:

$ tree vendor/javascript/
vendor/javascript/
├── #dist--modules--src--node.js.js
└── mediabunny.js

And this error in the console:

[Error] Failed to register controller: preupload-transcode (controllers/some_controller) – TypeError: Module name, '#dist/modules/src/node.js' does not resolve to a valid URL.
TypeError: Module name, '#dist/modules/src/node.js' does not resolve to a valid URL.
	error

I tried jsdelivr as well:

$ bin/importmap pin mediabunny --from jsdelivr
Pinning "https://cdn.jsdelivr.net/npm/[email protected]/dist/modules/src/node.js" to vendor/javascript/https://cdn.jsdelivr.net/npm/[email protected]/dist/modules/src/node.js.js via download from https://cdn.jsdelivr.net/npm/@jspm/[email protected]/nodelibs/@empty.js
Pinning "mediabunny" to vendor/javascript/mediabunny.js via download from https://cdn.jsdelivr.net/npm/[email protected]/dist/modules/src/index.js

Which gave me this importmap.rb:

# config/importmap.rb
pin "https://cdn.jsdelivr.net/npm/[email protected]/dist/modules/src/node.js", to: "https:----cdn.jsdelivr.net--npm--mediabunny@1.24.2--dist--modules--src--node.js.js" # @2.1.0
pin "mediabunny" # @1.24.2

And these files:

$ tree vendor/javascript/
vendor/javascript/
├── https:----cdn.jsdelivr.net--npm--mediabunny@1.24.2--dist--modules--src--node.js.js
└── mediabunny.js

And a bunch more console errors:

[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (output.js, line 0)
[Error] Failed to register controller: preupload-transcode (controllers/preupload_transcode_controller)
TypeError: Importing a module script failed.
	error
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (output-format.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (media-source.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (codec.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (target.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (encode.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (source.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (input-format.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (input.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (input-track.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (packet.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (sample.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (media-sink.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (conversion.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (custom-coder.js, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (tags.js, line 0)

Does anyone have any advice on how to add dependencies like this one? I can manually hack at the mediabunny file and remove the erroneous import but obviously that breaks update/pristine and any other commands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions