Open daybrush opened 5 years ago
What version of karma-typescript are you running?
The currently applied karma-typescript version is 3.0.13.
The versions of modules related to karma are as follows.
"karma": "^1.7.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-typescript": "^3.0.13",
files: [
"./src/**/*.ts",
"./test/**/*.ts",
// "./test/**/*.spec.ts",
],
preprocessors: {
"src/**/*.ts": ["karma-typescript"],
"test/**/*.ts": ["karma-typescript"],
},
karmaTypescriptConfig: {
tsconfig: "./tsconfig.test.json",
reports: {
html: {
"directory": "coverage",
"subdirectory": "./"
},
lcovonly: {
"directory": "coverage",
"filename": "lcov.info",
"subdirectory": "."
},
},
coverageOptions: {
instrumentation: true,
exclude: /test/i,
},
},
{
"extends": "./tsconfig",
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"types": [
"karma-chai",
"mocha"
],
},
"include": [
"./src/**/*.ts",
"./test/**/*.ts"
]
}
Error2, Added bundleItem.isTypingFile()
in the dist/...api/bundler/resolve/resolver.js file.
I'm ran into the similar issue. This happens because @daybrush/utils/declaration/consts.d
is interpreted as a npmModule. In resolver.ts, there is the following snippet, where moduleName is your file path
if (bundleItem.isTypescriptFile() && !bundleItem.isNpmModule()) {
process.nextTick(() => {
onModuleResolved(bundleItem);
});
return;
}
public isNpmModule(): boolean {
return this.moduleName.charAt(0) !== "." && this.moduleName.charAt(0) !== "/";
}
Since file path doesn't start with "." or "/" it is considered an npm module and can't be resolved and throws the error down the line.
@erikbarke , can the isNpmModule condition be improved to handle tsconfig paths correctly? I could make a PR to check if filename is present, whether filename contains "node_modules", but it's prone to false positives if some other folder on the path or filename itself contain 'node_modules' substring.
Workaround with the existing version is to set
karmaTypescriptConfig {
bundlerOptions: {
exclude: [
"@daybrush/utils/declaration/consts.d"
]
}
}
@ssivov, PR:s are always welcome!
@erikbarke Is this maybe a duplicate of #261?
An error occurs when importing a declaration file.
error 1
error 2
declaration
tosrc
. This is probably related to theisTypingFile
method.