Email or username:

Password:

Forgot your password?
Axel Rauschmayer

“package.json contains a local aliasing mechanism for import paths called ‘imports’. It satisfies many use cases without tooling-specific solutions like tsconfig.json.”
socket.dev/blog/we-don-t-need- #JavaScript

package.json
{
"imports": {
"#components": {
"browser": "./src/components/client/*",
"default": "./src/components/server/*"
}
}
}

my-module.js
import '#components/customer-table.js';

📖 Details (in my free online book on Node.js): exploringjs.com/nodejs-shell-s

3 comments
Ori Livni

@rauschma To my knowledge, tools don't support this good enough for now

Axel Rauschmayer

@oriSomething Can you be specific? I did a quick check and Vite and esbuild do support them. Which ones don’t?

The article says “almost every tool supports” it. It’d be nice to have some kind of compatibility table, though.

Ori Livni

@rauschma I remember Bryan from Reply IO complained about it. I think he uses Parcel

Go Up