Hooks loading `commonjs` files uses `import` condition for `require()`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
Version
21.5.0
Platform
macOS
Subsystem
No response
What steps will reproduce the bug?
Reproduction: https://github.com/privatenumber/bug-node-hooks-cjs-conditions
How often does it reproduce? Is there a required condition?
A Hook needs to be registered to load commonjs type files.
What is the expected behavior? Why is that the expected behavior?
For the conditions to include require when require(file) is executed.
What do you see instead?
The import conditions only include import.
Here are the logs:
resolve: {
"url": "file:///repro/src/index.cjs",
"context": {
"conditions": [
"node",
"import",
"node-addons"
],
"importAttributes": {}
}
}
load: {
"url": "file:///repro/src/index.cjs",
"context": {
"format": "commonjs",
"importAttributes": {}
}
}
resolve: {
"url": "file:///repro/src/file.cjs",
"context": {
"conditions": [
"node",
"import",
"node-addons"
],
"importAttributes": {},
"parentURL": "file:///repro/src/index.cjs"
}
}
load: {
"url": "file:///repro/src/file.cjs",
"context": {
"format": "commonjs",
"importAttributes": {}
}
}
Additional information
No response
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der verknüpften Reproduktion und untersuche die Hook-Kontexte resolve und load für CommonJS-Dateien. Vergleiche die gemeldeten Bedingungen während require(file) mit der erwarteten require-Bedingung; abgeschlossen ist es, wenn der Hook beim Laden von CommonJS-Dateien die korrekte Bedingung erhält und die Reproduktion nicht mehr nur import anzeigt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100