turbopack to support custom condition names for resolving package exports #78912
Replies: 4 comments 2 replies
-
|
I'm hitting this issue again in a different place. Some more detail about my use case: Problem statementI have a monorepo like:
When building Therefore, within this monorepo, when writing My attempted solutionThe modern way to do this seems to be:
{
"name": "my-components",
"type": "module",
"exports": {
"./*": {
"my-source": [
"./src/*/index.ts",
"./src/*/index.tsx",
"./src/*.tsx",
"./src/*.ts"
],
"typescript": ["./dist/*/index.d.ts", "./dist/*.d.ts"],
"default": ["./dist/*/index.js", "./dist/*.js"]
}
},
}Here, I've defined a custom condition name Then, I just need to tell all the bundlers within the monorepo to use this custom condition name I'd be also interested to know if there's a better way to solve my problem. |
Beta Was this translation helpful? Give feedback.
-
|
# |
Beta Was this translation helpful? Give feedback.
-
|
Material UI X (MUI X) is telling us to do this But how do you do that using turbopack instead of webpack? Quote from the document: Next.js Pages RouterWith Next.js App Router, you don't need to do anything. With Next.js Pages Router, update Next.js configuration to pass the export default {
webpack: (config) => {
// '...' is important here – it keeps the default webpack conditionNames
config.resolve.conditionNames = ['require', '...'];
return config;
},
transpilePackages: [
'@mui/x-data-grid',
'@mui/x-data-grid-pro',
'@mui/x-data-grid-premium',
'@mui/x-date-pickers',
'@mui/x-date-pickers-pro',
'@mui/x-charts',
'@mui/x-charts-pro',
'@mui/x-tree-view',
'@mui/x-tree-view-pro',
],
};
|
Beta Was this translation helpful? Give feedback.
-
|
Please advise what to do about turbopack instead of webpack (Next.js version 16, pages router) |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Support of custom condition names, to tell turbopack which conditions to apply when resolving package exports.
Non-Goals
N/A
Background
See node's documentation for background on package exports, and conditions.
Custom condition names can be passed into various other tools:
config.resolve.conditionNamescompilerOptions.customConditionsconfig.resolver.unstable_conditionNamesProposal
I feel like turbopack could emulate webpack's config interface, e.g. add a config option
resolveConditionNameswhich accepts an array of conditions, defaulting to['browser', 'require', 'import']or something like that.Beta Was this translation helpful? Give feedback.
All reactions