-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.9 breaking change] hostOrText.readFile is not a function #51644
Comments
can you please share project where i can repro this |
Sample project i created seems to work correctly // /src/math/index.ts
export function add(x: number, y: number): number {
return x + y;
}
export function substract(x: number, y: number): number {
return x - y;
} // /src/app.ts
import { add, substract } from './math';
const x = 20;
const y = 10;
console.log(`${x} + ${y} = ${add(x, y)}`)
console.log(`${x} - ${y} = ${substract(x, y)}`); // /tsconfig.json
{
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node",
"outDir": "output",
"rootDir": "./",
"composite": true
}
,
"include": ["./src/**/*.ts"]
} // /rollup.config.js
import typescript from 'rollup-plugin-typescript2';
export default {
input: 'src/app.ts',
output: {
dir: 'output',
format: 'cjs',
},
plugins: [typescript()],
}; // /package.json
{
"name": "typescript-rollup",
"version": "1.0.0",
"description": "",
"main": "output/app.js",
"type": "module",
"scripts": {
"build": " rollup -c rollup.config.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"rimraf": "^3.0.2",
"rollup": "^3.5.1",
"rollup-plugin-typescript2": "^0.34.1",
"tslib": "^2.4.1",
"typescript": "^4.9.3"
}
} Ran
|
This issue has been marked as 'External' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
closed over the weekend - harsh. One last question @sheetalkamat and thank you for taking the time to investigate. Was this a planned breaking change in the resolveHost? Like I mentioned in the post, this has worked for years. |
This is not breaking change per say... The API always used |
thank you! |
btw, for any future readers, a simple noop for readFile in the resolve host is all that is required.
|
@jeremy-coleman thanks for the heads up, however I don't get where we're supposed to add this? I didn't correctly understand the root-cause here but I face the same issue when trying to add a custom |
Modify the code of the plugin @nicolaschambrier |
Bug Report
🔎 Search Terms
hostOrText
hostOrText.readFile
🕗 Version & Regression Information
When did you start seeing this bug occur?
today, after upgrading a project
I tried both 4.9.3 and next versions, both have the error.
💻 Code
this is the source of the calling function https://github.com/microsoft/TypeScript/blob/main/src/compiler/utilities.ts#L6418
my code doesn't call hostOrText.readFile . I'm using a modified copy of rollup plugin typescript v2. It has worked for years, without change. I can copy/paste it here if wanted, but i think it'd be more clutter rather than providing anything useful.
for a little context, here is the project layout. its super simple. the rollup.bundles.js is just configured to export an array of rollup configs using the local typescript plugin.
Just Brainstorming: Possibly related to the new file watcher? I've written several cli tools and have experienced similar problems where chokidar would swallow errors but fs watch recursive would throw and exit. Another thought is maybe there is some change in logic for looking up the closest tsconfig file in a monorepo.
🙁 Actual behavior
error output when running rollup via an npm script
🙂 Expected behavior
output after downgrading to typescript 4.8.x or any other version
The text was updated successfully, but these errors were encountered: