-
-
Notifications
You must be signed in to change notification settings - Fork 433
Chain custom loaders to ts-loader #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Theoretically it should "just work" due to this. I'm guessing since you're posting this issue that it doesn't? There isn't currently a test for it unfortunately. |
From what I can tell it does not. If you need a generic custom loader I can whip one up. |
Looks like the program is marked as dirty off the bat when webpack serves the ts files via the loader. That way the changes are updated in the program. |
Apropos of nothing, welcome back @jbrantly! 🎉👍 |
Update, the array loader chain syntax does work, however the string syntax does not. |
@TheLarkInn are you the chap I heard on Adventures in Angular talking about WebPack? If so, I really enjoyed it; well done; |
I am @johnnyreilly. Thank you very much. I'm a strong Webpack ambassador to angular devs. Haha. If you frequent the ts-loader gitter, I'd like to talk to you and/or @jbrantly about the future of ts-loader etc. |
Hey @TheLarkInn,
I think I've had success with both approaches (assuming I'm understanding your meaning correctly). See this webpack.config.js : /* eslint-disable no-var, strict, prefer-arrow-callback */
'use strict';
var path = require('path');
var webpack = require('webpack');
var packageJson = require('./package.json');
module.exports = {
cache: true,
entry: {
main: './src/main.ts',
// common dependencies bundled together packaged with CommonsChunkPlugin in gulp/webpack.js
vendor: [
'babel-polyfill',
'angular',
'angular-animate',
'angular-ui-bootstrap',
'angular-ui-router'
]
},
output: {
path: path.resolve(__dirname, './dist/scripts'),
filename: '[name].js',
chunkFilename: '[chunkhash].js'
},
module: {
loaders: [{
test: /\.ts(x?)$/,
exclude: /node_modules/,
loader: 'babel-loader?presets[]=es2015!ts-loader'
}, {
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015']
}
}]
},
plugins: [ // Check gulp/webpack.js for build specific plugins
],
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['', '.ts', '.tsx', '.js']
},
}; Specifically, Have I understood you correctly? UPDATE: Actually, it looks like your talking about custom loaders being applied before ts-loader. That I haven't tried. |
Other way around, passing a loader to IE: |
Yup gotcha. The right to left evaluation thing always catches me out |
This bug occurs on my project too. I am using angular2-template-loader to edit the ts files before the compilation, but it looks like only the entrypoint files are transformed. All other files that are imported aren't transformed. |
@HennerM are you using the string-style.of chaining loaders? If so is recommend using the array style. |
It's working now. for everybody who experience the same issue: the ordering of the
|
@HennerM @johnnyreilly it still does not work, but I am not sure it is a TypeScript issue (@TheLarkInn wrote in microsoft/TypeScript#9017 about it) or ts-loader. I have attached a small project with reproducing of the issue. We use Do the following to reproduce the issue:
Actual behavior Expected behavior If you comment Seems that the issue happens because TypeScript loads some modules by itself omitting |
Also |
npm install --save-dev angular2-template-loader - TypeStrong/ts-loader#223
npm install --save-dev angular2-template-loader - TypeStrong/ts-loader#223
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
1 similar comment
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing as stale. Please reopen if you'd like to work on this further. |
I'm not sure why is this closed and there is no activity on this issue. I've debug the code for quite a bit and I don't see how this possibly could have ever worked. Unless you specify transpileOnly option for the loader the loader will always go to the file system to get the source it does not use the input provided by webpack. This makes chaining impossible. Especially in the case where my original file is nor ts nor tsx but some custom format transformed to TS and then fed to ts-loader. Actually the behavior in this case is very problematic as ts-loader finds totally invalid syntax on the file system, returns undefined (because it's not ts file) and then compiles the whole project. |
@efreeti I had the exact same idea and I'm pretty disappointed that this doesn't work. Have you found any workarounds for your use-case? |
Is there any way to chain custom loaders to
ts-loader
.Currently when you attempt to mutate a ts file before it makes it to
ts-loader
, the modifications are ignored. It appears it is because the typescript api is picking up the assets in the project rather than webpack serving.ts
files to it.For example,
awesome-typescript-loader
has auseWebpackText:
feature which fixes this. Is there anysupport for this?The text was updated successfully, but these errors were encountered: