fix node.js externals (#6530)
### Description
* Extend resolving to allow reference type for plugins
* add extensions for MainField
* add an option `import_externals` to context to specify externals
behavior for ESM imports
* false: require() is used
* true: import() is used and the module becomes an async module
* adds `import_externals: false` support for dynamic import
* adds `import_externals: true` support for normal import
see also https://github.com/vercel/next.js/pull/58129
### Testing Instructions
<!--
Give a quick description of steps to test your changes.
-->
Closes PACK-2011