From 45f37a2d84a07f8957df7b3bfb52a41f39ebb9df Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 5 Mar 2024 15:50:47 +0000 Subject: [PATCH] update test case to avoid error in turbopack and correctly test externals in webpack --- .../node_modules/conditional-exports-optout/package.json | 3 ++- .../node_modules/conditional-exports-optout/react.js | 6 ++++-- .../node_modules/conditional-exports-optout/react.mjs | 5 +++++ test/turbopack-tests-manifest.json | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/react.mjs diff --git a/test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/package.json b/test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/package.json index 3355c20aad28a..2a2cb8619af5d 100644 --- a/test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/package.json +++ b/test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/package.json @@ -11,7 +11,8 @@ "default": "./subpath.js" }, "./react": { - "import": "./react.js" + "import": "./react.mjs", + "default": "./react.js" }, "./package.json": "./package.json" } diff --git a/test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/react.js b/test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/react.js index 4f2c2283ed693..106488bacc46e 100644 --- a/test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/react.js +++ b/test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/react.js @@ -1,5 +1,7 @@ -import React from 'react' +const React = require('react') -export function getReactVersion() { +function getReactVersion() { return React.version } + +exports.getReactVersion = getReactVersion diff --git a/test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/react.mjs b/test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/react.mjs new file mode 100644 index 0000000000000..4f2c2283ed693 --- /dev/null +++ b/test/e2e/app-dir/app-external/node_modules/conditional-exports-optout/react.mjs @@ -0,0 +1,5 @@ +import React from 'react' + +export function getReactVersion() { + return React.version +} diff --git a/test/turbopack-tests-manifest.json b/test/turbopack-tests-manifest.json index 6499b757483ef..6316f60a7d0fb 100644 --- a/test/turbopack-tests-manifest.json +++ b/test/turbopack-tests-manifest.json @@ -2590,6 +2590,7 @@ "app dir - external dependency react in external esm packages should use the same react in server app", "app dir - external dependency server actions should compile server actions from node_modules in client components", "app dir - external dependency server actions should not prefer to resolve esm over cjs for bundling optout packages", + "app dir - external dependency should be able to opt-out 3rd party packages being bundled in server components", "app dir - external dependency should correctly collect global css imports and mark them as side effects", "app dir - external dependency should emit cjs helpers for external cjs modules when compiled", "app dir - external dependency should export client module references in esm", @@ -2606,7 +2607,6 @@ "app dir - external dependency should use the same export type for packages in both ssr and client" ], "failed": [ - "app dir - external dependency should be able to opt-out 3rd party packages being bundled in server components", "app dir - external dependency should not apply swc optimizer transform for external packages in browser layer in web worker" ], "pending": [],