Skip to content

Commit d4006c8

Browse files
authored
Fixed .mjs proxies generation in conditions builds (#567)
1 parent a096eaa commit d4006c8

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

.changeset/clean-crabs-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@preconstruct/cli": patch
3+
---
4+
5+
Fixed `.mjs` proxies generation with `___experimentalFlags_WILL_CHANGE_IN_PATCH.importsConditions` and `exports.importConditionDefaultExport: 'default'`

packages/cli/src/build/__tests__/imports-conditions.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ test("imports conditions", async () => {
129129
130130
exports.something = something;
131131
132+
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ dist/scope-pkg.browser.cjs.mjs ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
133+
export {
134+
something
135+
} from "./scope-pkg.browser.cjs.js";
136+
132137
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ dist/scope-pkg.browser.development.cjs.js ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
133138
'use strict';
134139
@@ -147,6 +152,11 @@ test("imports conditions", async () => {
147152
148153
exports.something = something;
149154
155+
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ dist/scope-pkg.browser.development.cjs.mjs ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
156+
export {
157+
something
158+
} from "./scope-pkg.browser.development.cjs.js";
159+
150160
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ dist/scope-pkg.browser.development.esm.js ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
151161
function something() {
152162
console.log("a");
@@ -217,6 +227,11 @@ test("imports conditions", async () => {
217227
218228
exports.something = something;
219229
230+
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ dist/scope-pkg.development.cjs.mjs ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
231+
export {
232+
something
233+
} from "./scope-pkg.development.cjs.js";
234+
220235
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ dist/scope-pkg.development.esm.js ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
221236
function something() {
222237
console.log("a");

packages/cli/src/build/rollup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export let getRollupConfig = (
149149
resolveErrorsPlugin(pkg, warnings, options.kind === "umd"),
150150
(options.kind === "node-prod" || isDefaultConditionsBuild) &&
151151
typescriptDeclarations(pkg),
152-
(options.kind === "node-prod" || isDefaultConditionsBuild) &&
152+
(options.kind === "node-prod" || options.kind === "conditions") &&
153153
pkg.exportsFieldConfig()?.importConditionDefaultExport === "default" &&
154154
mjsProxy(pkg),
155155
serverComponentsPlugin({ sourceMap: options.kind === "umd" }),

0 commit comments

Comments
 (0)