I finally find a reliable reproduction.
Repo: https://github.com/HerringtonDarkholme/ts-loader-hmr
TS file
// app.ts
import {test} from './import'
console.log(test)
// import.ts
export var test = '3333333'
if (module.hot) {
module.hot.accept()
}
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5"
},
"exclude": [
"node_modules", "dist"
]
}
webpack config
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './app.ts',
output: {
path: path.join(__dirname, 'dist'),
publicPath: 'dist/',
filename: 'build.js'
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{ test: /\.ts$/, use: {loader: 'ts-loader'} },
// toggle these lines to see HMR difference
// { test: /\.ts$/, use: {loader: 'ts-loader', options: {transpileOnly: true}} },
],
},
devServer: {
port: 8080,
host: 'localhost',
watchOptions: { aggregateTimeout: 300, poll: 1000 }
},
}
package.json
"devDependencies": {
"@types/webpack-env": "^1.12.1",
"ts-loader": "^1.3.3",
"typescript": "^2.1.4",
"webpack": "^2.2.0-rc.3",
"webpack-dev-server": "^2.2.0-rc.0"
},
I have also compared full-compiled and transpile files. They only differs in hotCurrentHash which I don't think is a relevant point here.
I finally find a reliable reproduction.
Repo: https://github.com/HerringtonDarkholme/ts-loader-hmr
TS file
tsconfig.json
webpack config
package.json
I have also compared full-compiled and transpile files. They only differs in hotCurrentHash which I don't think is a relevant point here.