Comments (8)
Hi @s-panferov, I have this problem. The only way to resolve it is to fallback to require
. I think this is because the typescript code is compiled before it's then sent into webpack, so the compiler throws an error stating modules can't be found. Here's some code (worked around): https://github.com/ahmednuaman/redux-counter/blob/master/src/js/angular2/buttons.component.ts#L2
I'll have a poke about the loader and hopefully send a PR soon. Thanks again.
from awesome-typescript-loader.
@MrMuh hello! I've just added an example for you: https://github.com/s-panferov/awesome-typescript-loader/tree/master/examples/alias
Please note, that you need to use rewriteImports
option which forces loader to rewrite import paths for you. Maybe we can throw this option out when something like microsoft/TypeScript#2338 will land.
from awesome-typescript-loader.
@MrMuh also please note, that such rewrites disable autocomplete features in IDEs right now, because it is a non-standard way of resolving modules.
IDEs will still work when you alias the root folder of your project, e.g.:
module.exports = {
resolve: {
extensions: ['', '.ts', '.js'],
alias: {
src: './src'
}
},
devtool: 'source-map',
module: {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader?module=common'
}
]
},
entry: {
index: ['./index.ts']
},
output: {
path: './dist',
filename: './[name].js'
}
};
import { Constants } from 'src/common/lib/util/constants';
console.log(Constants.Test);
You import is still remains absolute, but IDE works and you don't need rewriteImports
anymore.
from awesome-typescript-loader.
@s-panferov thank you very much for providing the sample and for pointing out the point with the IDE support; I switched to your absolute "src" approach so I can still make use of the IDE features 👍
from awesome-typescript-loader.
Hi there
I've just hit this issue, and the example no longer exists. How can I solve this?
from awesome-typescript-loader.
@raybooysen could you please describe the problem and your setup in a new issue?
from awesome-typescript-loader.
@s-panferov just to be complete, I no longer use aliases so I don't see this issue. Apologies for not responding.
from awesome-typescript-loader.
I have the same problem. I am using alias in webpack and typscript always complain that it "cannot find module 'shared-ng2/checkbox'. What are my other options then using require?
Appreciate your reply.
from awesome-typescript-loader.
Related Issues (20)
- Module build failed: Error: Final loader
- Strange characters in logging output
- Duplicated type-checking of shared files in client and server bundles
- TypeScript 3.4 --incremental support HOT 3
- Option configFileContent cannot set target, jsx
- how to use with Metro Bundler?
- Errors not printed in CI environment
- Slowdown with [email protected] HOT 2
- error width webpack4 HOT 1
- 'Cannot find module' when compile from node_modules
- How to make the compiled decorator code not different from typescript and babel?
- Dependencies (micromatch) Security Vulnerabilities HOT 1
- Npm install breaks - JSDoc types can only be used inside documentation comments.
- TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
- incompatibility with pnpm HOT 2
- Watch for changes in *.json files
- "events" module breaks awesome-typescript-loader
- Importing TypeScript files from node_modules causes errors
- Unclear to which lines error refers HOT 1
- FYI: performance up to x4 after switching to ts-loader
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awesome-typescript-loader.