Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resolving for esm package with only exports.import condition #42767

Merged
merged 2 commits into from Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/next/build/webpack-config.ts
Expand Up @@ -1641,7 +1641,7 @@ export default async function getBaseWebpackConfig(
return true
},
resolve: {
conditionNames: ['react-server', 'node', 'require'],
conditionNames: ['react-server', 'node', 'import', 'require'],
alias: {
// If missing the alias override here, the default alias will be used which aliases
// react to the direct file path, not the package name. In that case the condition
Expand Down Expand Up @@ -1983,9 +1983,7 @@ export default async function getBaseWebpackConfig(
new ReactLoadablePlugin({
filename: REACT_LOADABLE_MANIFEST,
pagesDir,
runtimeAsset: true
? `server/${MIDDLEWARE_REACT_LOADABLE_MANIFEST}.js`
: undefined,
runtimeAsset: `server/${MIDDLEWARE_REACT_LOADABLE_MANIFEST}.js`,
dev,
}),
(isClient || isEdgeServer) && new DropClientPage(),
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/app-dir/app-external.test.ts
Expand Up @@ -90,9 +90,9 @@ describe('app dir - external dependency', () => {
containClientContent(browserClientText)

// support esm module imports on server side, and indirect imports from shared components
expect(serverHtml).toContain('random-module-instance')
expect(serverHtml).toContain('pure-esm-module')
expect(sharedHtml).toContain(
'node_modules instance from client module random-module-instance'
'node_modules instance from client module pure-esm-module'
)
})

Expand Down
@@ -1,4 +1,4 @@
import { name } from 'random-module-instance'
import { name } from 'pure-esm-module'

export default function Page() {
return (
Expand Down
@@ -1,6 +1,6 @@
'use client'

import { name } from 'random-module-instance'
import { name } from 'pure-esm-module'

export default function () {
return `node_modules instance from client module ${name}`
Expand Down
@@ -1,2 +1,2 @@
export const random = ~~(Math.random() * 1e5)
export const name = 'random-module-instance'
export const name = 'pure-esm-module'
@@ -0,0 +1,7 @@
{
"name": "pure-esm-module",
"type": "module",
"exports": {
"import": "./index.js"
}
}

This file was deleted.

1 change: 0 additions & 1 deletion test/e2e/app-dir/rsc-basic/app/shared/page.js
@@ -1,7 +1,6 @@
import ClientFromDirect from '../../components/client'
import ClientFromShared from '../../components/shared'
import SharedFromClient from '../../components/shared-client'
// import Random from '../../components/random-module-instance'
import Bar from '../../components/bar'

export default function Page() {
Expand Down