feat(turbopack-ecmascript): Add implementation for webpackIgnore and turbopackIgnore (revision of #69113) (#69768)
## History
@arlyon was working on this in #69113. He's out of office, and this is a
feature we want to get landed soon, so I was seeing what needed to
happen to get it to merge.
I encountered more issues, and I didn't feel entirely comfortable
pushing deep changes to @arlyon's branch, so this builds on top of his
(rebased) commit.
This is my attempted PR to fix these problems.
## What?
*Copied from #69113's description.*
Certain bundles may be designed specifically to be included at runtime.
To support this usecase, webpack implemented a comment directive
`webpackIgnore` that opted out that particular import from bundle time
optimisations. We need to support this, as some libraries take advantage
of this (mapbox).
Closes PACK-3046
## Changes from #69113
- Bail out much earlier in the analysis. The other PR appeared to bail
out too late, and would generate a `Promise.resolve()` call, instead of
preserving `import`/`require`. My understanding of webpack's feature is
that it should include the `import`/`require`.
- Skip "too dynamic" analysis for ignored imports.
- Switch to a snapshot test, so that we can verify that the output
actually contains the `import`/`require` expressions.
- Integrates my changes from #69755 to use an `ImportOverrides` struct
instead of a bool.
---------
Co-authored-by: Alexander Lyon <arlyon@me.com>
Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>