JavaScript: moving an import ignores its import attributes
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, typescript
- Domain
- devtools
Research direction
Start with rewrite-javascript/rewrite/src/javascript/recipes/change-import.ts, especially ChangeImport and maybeRebind, to trace how moved members are joined to target imports. Check the JavaScript recipe tests for import-move cases and add coverage for matching and differing with/assert attributes. Done means members only join imports with identical attributes; otherwise they retain or receive a separate import statement.
Written by the indexing model from the issue text.
Description
ChangeImport (org.openrewrite.javascript.change-import, via maybeRebind) joins a moved member into an existing import of the target module without comparing import attributes. Attributes change how a module is loaded: with Bun, with {type: "macro"} runs the import at bundle time, so the member silently switches between bundle time and runtime.
1. Moved member loses its attributes
Move buildTime from ./macros/legacy.ts to ./macros/build.ts.
Before
import {buildTime} from "./macros/legacy.ts" with {type: "macro"};
import {gitHash} from "./macros/build.ts";
export const banner = `${buildTime()} ${gitHash()}`;
After (problem)
import {buildTime, gitHash} from "./macros/build.ts"; // ❌ buildTime is no longer a macro
After (expected)
import {buildTime} from "./macros/build.ts" with {type: "macro"};
import {gitHash} from "./macros/build.ts";
2. Plain member gains attributes
Move formatDate from ./util.ts to ./macros/build.ts.
Before
import {formatDate} from "./util.ts";
import {gitHash} from "./macros/build.ts" with {type: "macro"};
After (problem)
import {formatDate, gitHash} from "./macros/build.ts" with {type: "macro"}; // ❌ formatDate becomes a macro
After (expected)
import {formatDate} from "./macros/build.ts";
import {gitHash} from "./macros/build.ts" with {type: "macro"};
Expected rule: join a moved or added member only into an import with the same attributes (with and assert count as different); otherwise keep or add a statement of its own. The same applies to any attribute (type: "json", the legacy assert {…}).
- Dominant language
- Java
- Stars
- 3.9k
- Forks
- 599
- Avg merge
- 9h 38m
- Merged PRs (30d)
- 557
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openrewrite/rewrite
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
openrewrite/rewrite#9835 ·
Maintainers usually reply within 1 day
-
bug gradle
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
openrewrite/rewrite#7576 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
openrewrite/rewrite#9834 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
openrewrite/rewrite#9819 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 55/100
openrewrite/rewrite#9817 ·
Maintainers usually reply within 1 day
All issues in openrewrite/rewrite
Similar issues
-
Four TestConstraintBasedAlgorithm tests pass when nothing is thrownPossibly taken @sharanggupta claimed this today. Open
Difficulty 1/5 1-3 hours Newbie friendliness 85/100
-
bug documentation good first issue help wanted priority low size XS
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
martin-francois/symphony-trello#1351 ·
Maintainers usually reply within 1 day
-
Add test coverage for ConvertUtil.parseDate() with NULL inputPossibly taken @mirajul-mollah7 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 78/100
eclipse-sw360/sw360#4792 · 1 comment ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws/aws-emulator#30 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 4 days