Skip to content

Conversation

LukasBombach
Copy link
Contributor

@LukasBombach LukasBombach commented Mar 21, 2025

If you run this script from the deno website in Rustyscript

import * as emoji from "npm:node-emoji";

console.log(emoji.emojify(`:sauropod: :heart:  npm`));

(assuming you have installed node-emoji as a depency in your node_modules) you will get an error saying

Relative import path "@sindresorhus/is" not prefixed with / or ./ or ../ from "file:///.../node_modules/node-emoji/lib/index.js"

This is because node-emoji imports @sindresorhus/is" which has no npm: prefix and will not be treated as an npm package by Rustyscript.

To fix this, I implemented a check if a dependency is imported from within node_modules and then treat it as an npm package, wheather or not it has an npm: prefix or not.

The specific implementation is taken from deno itself: deno/resolvers/deno/lib.rs Lines 242-255, they too check if an import got initiated from within the node_modules and issue an npm-package-import.

@rscarson
Copy link
Owner

Fantastic! Thanks for fixing this!

I'll merge it as soon as the tests pass!

@LukasBombach
Copy link
Contributor Author

Thank you, currently trying to fix the tests!

@rscarson
Copy link
Owner

Lgtm!

@rscarson rscarson merged commit f85e33a into rscarson:master Mar 22, 2025
5 checks passed
@LukasBombach LukasBombach deleted the npm-dependencies-of-npm-dependencies branch March 22, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants