Skip to content

Commit

Permalink
@uppy/companion: fix esm imports in production/transpiled builds (#4561)
Browse files Browse the repository at this point in the history
TypeScript is used to transpile companion to CommonJS.
`require()` in CommonJS is synchronous and cannot be used to import packages using ESM syntax, which are asynchronous by spec.
If you want to import an ESM package, you need to use asynchronous dynamic `import()`.
By default TypeScript transpiles this to `Promise.resolve().then(() => require('webdav'))` which is obviously using synchronous `require` internally and breaks the import of ESM packages.
We need to switch `moduleResolution` to `node16` to make TypeScript not transpile the `import()` call.
  • Loading branch information
dschmidt authored Jul 11, 2023
1 parent bb9af8e commit 7dcf8c2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/@uppy/companion/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"outDir": "./lib",
"module": "commonjs",
"moduleResolution": "node16",
"declaration": true,
"target": "es6",
"noImplicitAny": false,
Expand Down

0 comments on commit 7dcf8c2

Please sign in to comment.