fix: use import-equals for slash to restore release uploads - #6
Open
JeanSilvany wants to merge 1 commit into
Open
fix: use import-equals for slash to restore release uploads#6JeanSilvany wants to merge 1 commit into
JeanSilvany wants to merge 1 commit into
Conversation
tsconfig.json does not enable esModuleInterop, so `import slash from
"slash"` compiles to a bare require() while still reading `.default`:
const slash_1 = require("slash"); // no __importDefault helper
(0, slash_1.default)(...) // .default is undefined
slash@1.0.0 is CommonJS (module.exports = fn) and has no `.default`, so
every release crashed while building the upload zip:
TypeError: (0 , slash_1.default) is not a function
at management-sdk.js:330
Enabling esModuleInterop would fix this import but also change
`import * as chalk` and `import * as yargs` into __importStar, replacing
those CommonJS module objects with synthesized namespaces — a far wider
behavioural change than this bug warrants.
The import-equals form is already the convention two lines above in the
same file, for q and superagent.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every
dpctl release-react/dpctl releasefails at upload time:The bundle is built successfully; the crash happens while walking the output folder to build the upload zip, so no release is ever created.
Cause
tsconfig.jsondoes not enableesModuleInterop, soimport slash from "slash"compiles to a barerequire()while still reading.default:slash@1.0.0(the pinned version) is CommonJS —module.exports = fn— so it has no.default.Why not
esModuleInterop: trueIt would fix this import, but the codebase also uses
import * as chalkandimport * as yargson CommonJS packages. WithesModuleInteropthose compile to__importStar, which replaces the module object with a synthesized namespace — a much wider behavioural change than this bug warrants.Fix
Use the import-equals form, which is already the convention two lines above in the same file for
qandsuperagent.Verification
npx tscbuilds clean; emitted output isconst relativePath = slash(path.relative(...)).packageFileFromPath()exercised directly against the built output: produces a valid zip with nested paths and forward slashes (which is whatslashis there for —yazlrejects backslashes in metadata paths).npm test: 107 passing / 8 failing, identical to the unmodified baseline. The 8 failures are pre-existing (local-cli/cli.jsfixture path) and unrelated to this change.Reproduced on Node v24.15.0, macOS.