v0.23.0+ doesn't resolve ts files included from js files
See original GitHub issueWhat happens and why it is wrong
The latest rpt2 (0.24.1) doesn’t resolve ts files included from js files.
This works under rpt2 0.22.1 and earlier.
Versions
- typescript: 3.6.2
- rollup: 1.21.2
- rollup-plugin-typescript2: 0.24.1
rollup.config.js
import typescript from "rollup-plugin-typescript2";
import commonjs from "rollup-plugin-commonjs";
import autoExternal from "rollup-plugin-auto-external";
const OUTPUT_DIR = process.env.OUTPUT_DIR || "build";
export default {
input: ["src/processors/new-message-processor.js"]
output: {
dir: OUTPUT_DIR,
format: "cjs"
},
external: ["nanoid/async"], // this one doesn't autoExtenal properly
plugins: [
autoExternal({
builtins: true // handles nodeJS builtins
}),
commonjs(),
typescript({
typescript: require("typescript"),
verbosity: 3
})
]
};
tsconfig.json
{
"compilerOptions": {
"module": "ESNext",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"noImplicitAny": true,
"outDir": "./build",
"target": "es2018",
"baseUrl": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "build"]
}
plugin output with verbosity 3
*Failing*
src/processors/new-message-processor.js → build...
rpt2: built-in options overrides: {
"noEmitHelpers": false,
"importHelpers": true,
"noResolve": false,
"noEmit": false,
"inlineSourceMap": false,
"outDir": "/Users/kylejohnson/Demeter/backend/node_modules/.cache/rollup-plugin-typescript2/placeholder",
"moduleResolution": 2,
"allowNonTsExtensions": true
}
rpt2: parsed tsconfig: {
"options": {
"module": 99,
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": 2,
"noImplicitAny": true,
"outDir": "/Users/kylejohnson/Demeter/backend/node_modules/.cache/rollup-plugin-typescript2/placeholder",
"target": 5,
"baseUrl": "/Users/kylejohnson/Demeter/backend/src",
"configFilePath": "/Users/kylejohnson/Demeter/backend/tsconfig.json",
"noEmitHelpers": false,
"importHelpers": true,
"noResolve": false,
"noEmit": false,
"inlineSourceMap": false,
"allowNonTsExtensions": true
},
"fileNames": [
// these don't differ between runs
],
"typeAcquisition": {
"enable": false,
"include": [],
"exclude": []
},
"raw": {
"compilerOptions": {
"module": "ESNext",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"noImplicitAny": true,
"outDir": "./build",
"target": "es2018",
"baseUrl": "./src"
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"build"
],
"compileOnSave": false
},
"errors": [],
"wildcardDirectories": {
"/users/kylejohnson/demeter/backend/src": 1
},
"compileOnSave": false,
"configFileSpecs": {
"includeSpecs": [
"src/**/*"
],
"excludeSpecs": [
"node_modules",
"build"
],
"validatedIncludeSpecs": [
"src/**/*"
],
"validatedExcludeSpecs": [
"node_modules",
"build"
],
"wildcardDirectories": {
"/users/kylejohnson/demeter/backend/src": 1
}
}
}
rpt2: typescript version: 3.6.2
rpt2: tslib version: 1.10.0
rpt2: rollup version: 1.21.2
rpt2: rollup-plugin-typescript2 version: 0.24.1
rpt2: plugin options:
{
"typescript": "version 3.6.2",
"verbosity": 3,
"check": true,
"clean": false,
"cacheRoot": "/Users/kylejohnson/Demeter/backend/node_modules/.cache/rollup-plugin-typescript2",
"include": [
"*.ts+(|x)",
"**/*.ts+(|x)"
],
"exclude": [
"*.d.ts",
"**/*.d.ts"
],
"abortOnError": true,
"rollupCommonJSResolveHack": false,
"useTsconfigDeclarationDir": false,
"tsconfigOverride": {},
"transformers": [],
"tsconfigDefaults": {},
"objectHashIgnoreUnknownHack": false
}
rpt2: rollup config:
{
"chunkGroupingSize": 5000,
"experimentalCacheExpiry": 10,
"external": [
// from node_modules, doesn't vary between runs
],
"inlineDynamicImports": false,
"input": [
"src/processors/new-message-processor.js"
],
"perf": false,
"plugins": [
{
"name": "auto-external"
},
{
"name": "commonjs"
},
{
"name": "rpt2"
}
],
"strictDeprecations": false
}
rpt2: tsconfig path: /Users/kylejohnson/Demeter/backend/tsconfig.json
rpt2: included:
[
"*.ts+(|x)",
"**/*.ts+(|x)"
]
rpt2: excluded:
[
"*.d.ts",
"**/*.d.ts"
]
[!] Error: Could not resolve '../utils' from src/processors/new-message-processor.js
Error: Could not resolve '../utils' from src/processors/new-message-processor.js
at error (/Users/kylejohnson/Demeter/backend/node_modules/rollup/dist/rollup.js:9558:30)
at ModuleLoader.handleMissingImports (/Users/kylejohnson/Demeter/backend/node_modules/rollup/dist/rollup.js:16628:17)
at ModuleLoader.<anonymous> (/Users/kylejohnson/Demeter/backend/node_modules/rollup/dist/rollup.js:16679:26)
at Generator.next (<anonymous>)
at fulfilled (/Users/kylejohnson/Demeter/backend/node_modules/rollup/dist/rollup.js:40:28)
error Command failed with exit code 1.
*Working*
src/processors/new-message-processor.js → build...
rpt2: built-in options overrides: {
"noEmitHelpers": false,
"importHelpers": true,
"noResolve": false,
"noEmit": false,
"inlineSourceMap": false,
"outDir": "/Users/kylejohnson/Demeter/backend/.rpt2_cache/placeholder",
"moduleResolution": 2,
"allowNonTsExtensions": true
}
rpt2: parsed tsconfig: {
"options": {
"module": 99,
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": 2,
"noImplicitAny": true,
"outDir": "/Users/kylejohnson/Demeter/backend/.rpt2_cache/placeholder",
"target": 5,
"baseUrl": "/Users/kylejohnson/Demeter/backend/src",
"configFilePath": "/Users/kylejohnson/Demeter/backend/tsconfig.json",
"noEmitHelpers": false,
"importHelpers": true,
"noResolve": false,
"noEmit": false,
"inlineSourceMap": false,
"allowNonTsExtensions": true
},
"fileNames": [
// same as above
],
"typeAcquisition": {
"enable": false,
"include": [],
"exclude": []
},
"raw": {
"compilerOptions": {
"module": "ESNext",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"noImplicitAny": true,
"outDir": "./build",
"target": "es2018",
"baseUrl": "./src"
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"build"
],
"compileOnSave": false
},
"errors": [],
"wildcardDirectories": {
"/users/kylejohnson/demeter/backend/src": 1
},
"compileOnSave": false,
"configFileSpecs": {
"includeSpecs": [
"src/**/*"
],
"excludeSpecs": [
"node_modules",
"build"
],
"validatedIncludeSpecs": [
"src/**/*"
],
"validatedExcludeSpecs": [
"node_modules",
"build"
],
"wildcardDirectories": {
"/users/kylejohnson/demeter/backend/src": 1
}
}
}
rpt2: typescript version: 3.6.2
rpt2: tslib version: 1.10.0
rpt2: rollup version: 1.21.2
rpt2: rollup-plugin-typescript2 version: 0.22.1
rpt2: plugin options:
{
"typescript": "version 3.6.2",
"verbosity": 3,
"check": true,
"clean": false,
"cacheRoot": "/Users/kylejohnson/Demeter/backend/.rpt2_cache",
"include": [
"*.ts+(|x)",
"**/*.ts+(|x)"
],
"exclude": [
"*.d.ts",
"**/*.d.ts"
],
"abortOnError": true,
"rollupCommonJSResolveHack": false,
"useTsconfigDeclarationDir": false,
"tsconfigOverride": {},
"transformers": [],
"tsconfigDefaults": {},
"objectHashIgnoreUnknownHack": false
}
rpt2: rollup config:
{
"chunkGroupingSize": 5000,
"experimentalCacheExpiry": 10,
"external": [
// same as above
],
"inlineDynamicImports": false,
"input": [
"src/processors/new-message-processor.js"
],
"perf": false,
"plugins": [
{
"name": "auto-external"
},
{
"name": "commonjs"
},
{
"name": "rpt2"
}
],
"strictDeprecations": false
}
rpt2: tsconfig path: /Users/kylejohnson/Demeter/backend/tsconfig.json
rpt2: included:
[
"*.ts+(|x)",
"**/*.ts+(|x)"
]
rpt2: excluded:
[
"*.d.ts",
"**/*.d.ts"
]
rpt2: Ambient types:
rpt2: /Users/kylejohnson/Demeter/backend/src/global.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/accepts/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/babel__core/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/babel__generator/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/babel__template/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/babel__traverse/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/bl/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/body-parser/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/caseless/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/connect/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/cookies/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/eslint-visitor-keys/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/estree/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/events/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/express/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/express-serve-static-core/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/form-data/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/formidable/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/http-assert/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/istanbul-lib-coverage/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/istanbul-lib-report/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/istanbul-reports/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/jest/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/jest-diff/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/json-schema/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/json5/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/jsonwebtoken/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/keygrip/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/koa/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/koa-compose/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/koa-router/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/long/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/mime/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/node/ts3.2/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/pg/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/pg-types/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/pino/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/pino-std-serializers/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/range-parser/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/request/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/resolve/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/serve-static/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/sonic-boom/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/stack-utils/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/stream-to-array/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/tough-cookie/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/yargs/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/yargs-parser/index.d.ts
rpt2: /Users/kylejohnson/Demeter/backend/node_modules/@types/yauzl/index.d.ts
rpt2: ambient types changed, redoing all semantic diagnostics
rpt2: dependency '/Users/kylejohnson/Demeter/backend/src/utils.ts'
rpt2: imported by '/Users/kylejohnson/Demeter/backend/src/processors/new-message-processor.js'
rpt2: resolving '../utils' imported by '/Users/kylejohnson/Demeter/backend/src/processors/new-message-processor.js'
rpt2: to '/Users/kylejohnson/Demeter/backend/src/utils.ts'
rpt2: dependency '/Users/kylejohnson/Demeter/backend/src/processors/message-handler-framework.ts'
rpt2: imported by '/Users/kylejohnson/Demeter/backend/src/processors/new-message-processor.js'
rpt2: resolving './message-handler-framework' imported by '/Users/kylejohnson/Demeter/backend/src/processors/new-message-processor.js'
rpt2: to '/Users/kylejohnson/Demeter/backend/src/processors/message-handler-framework.ts'
rpt2: dependency '/Users/kylejohnson/Demeter/backend/src/buffered-channel.ts'
rpt2: imported by '/Users/kylejohnson/Demeter/backend/src/processors/new-message-processor.js'
rpt2: resolving '../buffered-channel' imported by '/Users/kylejohnson/Demeter/backend/src/processors/new-message-processor.js'
rpt2: to '/Users/kylejohnson/Demeter/backend/src/buffered-channel.ts'
rpt2: transpiling '/Users/kylejohnson/Demeter/backend/src/utils.ts'
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/code/cache/6895f7e81850383bec8a4facc7e6e179d2c36c2a'
rpt2: cache miss
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/syntacticDiagnostics/cache/6895f7e81850383bec8a4facc7e6e179d2c36c2a'
rpt2: cache miss
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/semanticDiagnostics/cache/6895f7e81850383bec8a4facc7e6e179d2c36c2a'
rpt2: cache miss
rpt2: transpiling '/Users/kylejohnson/Demeter/backend/src/processors/message-handler-framework.ts'
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/code/cache/bd72d31b4317d7b2d9cd3f1d29bc790c76468d5a'
rpt2: cache miss
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/syntacticDiagnostics/cache/bd72d31b4317d7b2d9cd3f1d29bc790c76468d5a'
rpt2: cache miss
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/semanticDiagnostics/cache/bd72d31b4317d7b2d9cd3f1d29bc790c76468d5a'
rpt2: cache miss
rpt2: dependency '/Users/kylejohnson/Demeter/backend/src/aws.ts'
rpt2: imported by '/Users/kylejohnson/Demeter/backend/src/processors/message-handler-framework.ts'
rpt2: resolving '../aws' imported by '/Users/kylejohnson/Demeter/backend/src/processors/message-handler-framework.ts'
rpt2: to '/Users/kylejohnson/Demeter/backend/src/aws.ts'
rpt2: transpiling '/Users/kylejohnson/Demeter/backend/src/buffered-channel.ts'
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/code/cache/6a7cbb15c399dd3ba3546f1ccc0686609add6344'
rpt2: cache miss
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/syntacticDiagnostics/cache/6a7cbb15c399dd3ba3546f1ccc0686609add6344'
rpt2: cache miss
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/semanticDiagnostics/cache/6a7cbb15c399dd3ba3546f1ccc0686609add6344'
rpt2: cache miss
rpt2: dependency '/Users/kylejohnson/Demeter/backend/src/aws.ts'
rpt2: imported by '/Users/kylejohnson/Demeter/backend/src/buffered-channel.ts'
rpt2: resolving './aws' imported by '/Users/kylejohnson/Demeter/backend/src/buffered-channel.ts'
rpt2: to '/Users/kylejohnson/Demeter/backend/src/aws.ts'
rpt2: transpiling '/Users/kylejohnson/Demeter/backend/src/aws.ts'
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/code/cache/cc5447b8d6c1f999fb4bf4c04b2704ed191d0f41'
rpt2: cache miss
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/syntacticDiagnostics/cache/cc5447b8d6c1f999fb4bf4c04b2704ed191d0f41'
rpt2: cache miss
rpt2: cache: '/Users/kylejohnson/Demeter/backend/.rpt2_cache/rpt2_7949c609ec7b2114d4476feb47433d93ccf7c5ed/semanticDiagnostics/cache/cc5447b8d6c1f999fb4bf4c04b2704ed191d0f41'
rpt2: cache miss
rpt2: generating target 1
rpt2: rolling caches
created build in 18.3s
✨ Done in 19.30s.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
TSConfig Reference - Docs on every TSConfig option
This includes generating a type for the import based on the static JSON shape. TypeScript does not support resolving JSON files by default:...
Read more >Typescript module path resolution not working for .js files
I fixed it by using two loaders for Typescript files in webpack. { test: /\.js$/, exclude: /node_modules/, use: [ 'thread-loader', ...
Read more >Common TypeScript module problems and how to solve them
Solution 1: Locate the correct directory When we use this configuration, TypeScript compiler “jumps” up a directory from the src directory and ...
Read more >Node.js v19.3.0 Documentation
If the snapshot file does not exist, it is created. The --update-assert-snapshot command line flag can be used to force the update of...
Read more >Configuring Jest
For example, you may hide coverage report lines for all fully-covered files: JavaScript; TypeScript. /** @type {import('jest').Config} */
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
0.24.3 doesn’t fix the issue for me. I have a simple project that last worked on 0.22.1
Results in the following error:
@nickbabcock your stuff seem to compile if I change import to
./core/vigenere-cipher.ts
. Can’t tell if the bundle is correct or not.Looks like rpt2 doesn’t resolve the import itself because source file is not even js and whatever ends up resolving import for rollup doesn’t recognize ts files.