-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
feature request: createRequire detect #14228
Copy link
Copy link
Closed
Labels
Description
Feature request
What is the expected behavior?
For code like below:
import { createRequire as _createRequire } from 'module'
const __require = _createRequire(import.meta.url)__require should be detected as an alias of CommonJS require and the imported module of __require should be the type of javascript/auto instead of javascript/esm.
What is motivation or use case for adding/changing the behavior?
This allows webpack to bundle this format of ESModule projects.
And TypeScript is going to add Node-12 module emit which will generate code like above.
How should this be implemented in your opinion?
Detect import of module module and track the pattern of const $requireAlias = $importedCreateRequire(import.meta.url).
Are you willing to work on this yourself?
yes but I'm not familiar with webpack internal.
Reactions are currently unavailable