Closed
Description
Expected Behaviour
options.configFile
should allow passing in undefined
to fallback the standard config file
We hit this with a webpack config generator function that looks like:
function createWebpackConfig(configFileName: string | undefined) {
...
}
Sometimes we want to override the config file but usually we do not
Actual Behaviour
Passing in undefined
produces the following build error:
Module build failed (from ./node_modules/ts-loader/index.js):
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at validateString (internal/validators.js:124:11)
at Object.isAbsolute (path.js:1133:5)
at findConfigFile (/workspaces/ts-loader/examples/vanilla/node_modules/ts-loader/dist/config.js:57:14)
at Object.getConfigFile (/workspaces/ts-loader/examples/vanilla/node_modules/ts-loader/dist/config.js:8:28)
at successfulTypeScriptInstance (/workspaces/ts-loader/examples/vanilla/node_modules/ts-loader/dist/instances.js:74:40)
at Object.getTypeScriptInstance (/workspaces/ts-loader/examples/vanilla/node_modules/ts-loader/dist/instances.js:42:12)
at Object.loader (/workspaces/ts-loader/examples/vanilla/node_modules/ts-loader/dist/index.js:16:41)
Again, I'd expect undefined
to be treated as if the configFile
property has been omitted entirely
Steps to Reproduce the Problem
- In
examples/vanilla
, update the rules to:
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
configFile: undefined
}
}
]
- Now build:
yarn run build
Location of a Minimal Repository that Demonstrates the Issue.
Apply this diff in this repo:
diff --git a/examples/vanilla/webpack.config.js b/examples/vanilla/webpack.config.js
index 32e454fe..ae9fb98d 100644
--- a/examples/vanilla/webpack.config.js
+++ b/examples/vanilla/webpack.config.js
@@ -13,7 +13,10 @@ module.exports = {
rules: [
{
test: /\.tsx?$/,
- loader: 'ts-loader'
+ loader: 'ts-loader',
+ options: {
+ configFile: undefined
+ }
}
]
},
Metadata
Metadata
Assignees
Labels
No labels