Title: Transform readFile/writeFile methods are not called · Issue #3022 · AssemblyScript/assemblyscript · GitHub
Open Graph Title: Transform readFile/writeFile methods are not called · Issue #3022 · AssemblyScript/assemblyscript
X Title: Transform readFile/writeFile methods are not called · Issue #3022 · AssemblyScript/assemblyscript
Description: I have: Searched in the repository for existing result Developed a POC to fix this issue at ye-yu/assemblyscript@23cdb69 I have a sample code fix on readFile in my fork that I would like to contribute to this repository as a fix to this ...
Open Graph Description: I have: Searched in the repository for existing result Developed a POC to fix this issue at ye-yu/assemblyscript@23cdb69 I have a sample code fix on readFile in my fork that I would like to contrib...
X Description: I have: Searched in the repository for existing result Developed a POC to fix this issue at ye-yu/assemblyscript@23cdb69 I have a sample code fix on readFile in my fork that I would like to contrib...
Opengraph URL: https://github.com/AssemblyScript/assemblyscript/issues/3022
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Transform readFile/writeFile methods are not called","articleBody":"I have:\n- [x] Searched in the repository for existing result\n- [x] Developed a POC to fix this issue at [ye-yu/assemblyscript@23cdb69](https://github.com/ye-yu/assemblyscript/commit/23cdb698b63f748bdecd2063e1fde15f52aa73a0)\n\nI have a sample code fix on `readFile` in my fork that I would like to contribute to this repository as a fix to this issue. I would like to obtain suggestions and discussions on how to fix this issue before submitting a PR.\n\n### Bug description\n\nCustom compiler transformers extending Transform do not reliably receive readFile / writeFile calls during compilation. This prevents transformer implementations from intercepting file I/O and breaks transform-based file resolution.\n\n**Actual behavior**\n\n- Transform.prototype.readFile / writeFile are not properly wired for derived transformer classes.\nsuper.readFile(filename, baseDir) can fail or be skipped.\n- When multiple transformers are configured, the first transformer that returns a result should short-circuit, but current handling does not consistently enforce that.\n\n**Expected behavior**\n- A transformer subclass should be able to override readFile and writeFile and have those methods called during compilation.\n- Calling super.readFile(...) inside an override should delegate to the next transform or the default loader.\nIf multiple transformers are configured, the first non-null result should be used and remaining transformers should not override it.\n\n---\n\nMy use case: another source to source on top of AS transpiler\n\nI would like to develop a feature that will transform unsupported syntaxes to an intermediary source to work around some limitation. I'd figure that a transformer that was promised to me in this documentation [Compiler - Transforms - readFile](https://www.assemblyscript.org/compiler.html#transforms) would work. However, it did not return the expected result :( \n### Steps to reproduce\n\n1. In [tests/transform/index.js](https://github.com/AssemblyScript/assemblyscript/blob/main/tests/transform/index.js#L4-L19), add a tracking variable `readFileCalled` and override `readFile` method to update this variable\n\n ```diff,ts\n var constructorCalled = false;\n var afterParseCalled = false;\n var afterInitializeCalled = false;\n var afterCompileCalled = false;\n + var readFileCalled = false;\n \n console.log(\"Transform loaded\");\n \n export default class MyTransform extends Transform {\n // ...\n \n readFile(filename, baseDir) {\n + readFileCalled = true;\n return super.readFile(filename, baseDir);\n }\n\n // ...\n ```\n\n2. Assert `readFile` is called on `afterParse`\n3. Run `npm run test:transformer`\n\nExpected result: `readFileCalled` is true\nActual result: `readFileCalled` is false\n\n### AssemblyScript version\n\nv0.28.17","author":{"url":"https://github.com/ye-yu","@type":"Person","name":"ye-yu"},"datePublished":"2026-04-29T08:20:49Z","url":"https://github.com/AssemblyScript/assemblyscript/issues/3022"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ee6559fd-7443-35bd-9b2b-b9d0f3b7e940 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E732:34D604:22E0508:2E21C0E:6B0051DC |
| html-safe-nonce | f36f1541f8835f29d7ddfb02714d63a3a24dcd792299b1d921eee2a5a15f2996 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzMyOjM0RDYwNDoyMkUwNTA4OjJFMjFDMEU6NkIwMDUxREMiLCJ2aXNpdG9yX2lkIjoiNTE4NTE0MjkwMjQ2Mzk0MzEzMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 69c171383cfa1698e058414e3e65efc4bc0750f7e3243ea0d07f69c6bb0928fb |
| hovercard-subject-tag | issue:4348946671 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/AssemblyScript/assemblyscript/3022/issue_layout |
| twitter:image | https://opengraph.githubassets.com/213df51d20da1482812b436fa805df5723c5fda054875aeda0e58d85c279581a/AssemblyScript/assemblyscript/issues/3022 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/213df51d20da1482812b436fa805df5723c5fda054875aeda0e58d85c279581a/AssemblyScript/assemblyscript/issues/3022 |
| og:image:alt | I have: Searched in the repository for existing result Developed a POC to fix this issue at ye-yu/assemblyscript@23cdb69 I have a sample code fix on readFile in my fork that I would like to contrib... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ye-yu |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| turbo-cache-control | no-preview |
| go-import | github.com/AssemblyScript/assemblyscript git https://github.com/AssemblyScript/assemblyscript.git |
| octolytics-dimension-user_id | 28916798 |
| octolytics-dimension-user_login | AssemblyScript |
| octolytics-dimension-repository_id | 105138356 |
| octolytics-dimension-repository_nwo | AssemblyScript/assemblyscript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 105138356 |
| octolytics-dimension-repository_network_root_nwo | AssemblyScript/assemblyscript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width