-
Notifications
You must be signed in to change notification settings - Fork 179
Cannot find name 'require'.
when specifying tsconfig path.
#252
Comments
{
"name": "test",
"version": "0.1.0",
"scripts": {
"build": "webpack --config webpack.config.js"
},
"devDependencies": {
"@types/node": "^6.0.45",
"awesome-typescript-loader": "^2.2.4",
"json-loader": "^0.5.4",
"typescript": "^2.0.3",
"webpack": "^1.13.2"
}
}
module.exports = {
entry: './test.ts',
output: {
filename: "test.js"
},
module: {
loaders: [
{ test: /\.json$/, loader: 'json-loader' },
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
query: {
tsconfig: './tsconfig.json'
}
}
]
},
resolve: {
// Add '.ts' as resolvable extensions.
extensions: ['', '.webpack.js', '.web.js', '.js', '.ts']
}
} |
@vidartf did you ever find a solution for this? |
My workaround was to put a dummy {
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"moduleResolution": "node"
}
} |
I'd love to have a proper solution though, as the dummy might be confusing to others 👎 |
The solution is to specify the config filename using the query entry query: {
tsconfig: './tsconfig.json'
} |
Documentation fixed in #258. |
I can still reproduce this issue on my machine, using atl@3.0.0-beta.12 to 14 (I haven't tried older versions). My workaround was to explicitly declare main.ts: /// <reference types="core-js" />
/// <reference types="node" /> That fixed the unknown type definition errors. |
@voxmatt @vidartf @losnir it appears that at-loader isn't correctly handling the tsconfig.json:
Once I added this in and ran the webpack build again, everything worked fine. I think that at-loader should handle this implicitly, because tsc itself is able to without having this line in the tsconfig file. |
@voxmatt worked for me, with a small change: note |
When using ATL in a minimal webpack setup, with a file
data.json
(content e.g.[1,2,3]
) the TS code:will normally compile correctly, unless you specify
in the ATL loader configuration in the webpack config. If this configuration is present, the compilation fails with the error:
The text was updated successfully, but these errors were encountered: