Absolute imports / TS Paths aliases get treated as externals
See original GitHub issueHi. I am trying to create a small components lib + styleguidist playground.
Playground works fine (it uses webpack), but my build is broken. I created a dist folder, npm pack-ed it, installed locally in another project.
import { Button } from "components-lib";
Module not found: Can’t resolve ‘components/Button’
My index.ts looks like this:
export { default as Button } from "components/Button";
export { default as Checkbox } from "components/Checkbox";
export { default as Icon } from "components/Icon";
export { default as SideMenu } from "components/SideMenu";
I get no errors during build.
My tsconfig:
{
"include": ["src", "@types", "test"],
"compilerOptions": {
"target": "es5",
"module": "esnext",
"lib": ["dom", "esnext"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./",
"strict": true,
"noImplicitAny": false,
"strictNullChecks": false,
"strictFunctionTypes": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"baseUrl": "./",
"paths": {
"*": ["src/*", "node_modules/*"]
},
"jsx": "react",
"resolveJsonModule": true,
"esModuleInterop": true,
"isolatedModules": true,
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Advanced Features: Absolute Imports and Module Path Aliases
Configure module path aliases that allow you to remap certain import paths. ... Note: jsconfig.json can be used when you don't use TypeScript....
Read more >Typescript — How to solve the problem with unresolved path ...
Path aliases are defined as an array of key-value objects with the “paths”: key. Paths setting, usually require to set also the “baseUrl”...
Read more >Refactor aliased @ imports to relative paths - Stack Overflow
Three possible solutions that rewire aliased imports to relative paths: 1. babel-plugin-module-resolver. Use babel-plugin-module-resolver ...
Read more >Documentation - Module Resolution - TypeScript
A relative import is resolved relative to the importing file and cannot resolve to an ambient module declaration. You should use relative imports...
Read more >jsconfig.json Reference - Visual Studio Code
... Studio Code are treated as independent units. As long as a file a.js doesn't reference a file b.ts explicitly (either using import...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This could be related with how externals are configured (which I found recently): https://github.com/jaredpalmer/tsdx/issues/6#issuecomment-593146533
Try using relative imports, e.g.
Same goes for your static assets, assuming you’re importing them.
Yeah unfortunately the rollup config has a lot to be desired in that way.
For rollup aliases appear to be possible, see: https://github.com/rollup/plugins/tree/master/packages/alias