Unverified Commit 7a318128 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

chore: Remove unused `Map` support from `next/dynamic` transform (#82487)

Noticed while skimming over this code.

It looks like `react-loadable` had a separate `Loadable.Map` API (https://github.com/jamiebuilds/react-loadable/tree/master?tab=readme-ov-file#loading-multiple-resources), but `next/dynamic` doesn't, so we shouldn't check for this.

The SWC version of this transform doesn't appear to have copied this code, and doesn't have the `Map` logic.
parent 2036a5b1
......@@ -19,9 +19,13 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWAR
*/
// This file is https://github.com/jamiebuilds/react-loadable/blob/master/src/babel.js
// Modified to also look for `next/dynamic`
// Modified to put `webpack` and `modules` under `loadableGenerated` to be backwards compatible with next/dynamic which has a `modules` key
// Modified to support `dynamic(import('something'))` and `dynamic(import('something'), options)
// - Modified to also look for `next/dynamic`
// - Modified to put `webpack` and `modules` under `loadableGenerated` to be
// backwards compatible with next/dynamic which has a `modules` key
// - Modified to support `dynamic(import('something'))` and
// `dynamic(import('something'), options)
// - Removed `Loadable.Map` support, `next/dynamic` uses overloaded arguments
// instead of a separate API
import type {
NodePath,
......@@ -60,20 +64,6 @@ export default function ({
binding.referencePaths.forEach((refPath) => {
let callExpression = refPath.parentPath
if (
callExpression?.isMemberExpression() &&
callExpression.node.computed === false
) {
const property = callExpression.get('property')
if (
!Array.isArray(property) &&
property.isIdentifier({ name: 'Map' })
) {
callExpression = callExpression.parentPath
}
}
if (!callExpression?.isCallExpression()) return
let args = callExpression.get('arguments')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment