From 93972dcbea21e47c9388f28671d26d151ca653a3 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sat, 8 Jul 2023 10:01:35 +0200 Subject: [PATCH] @uppy/companion: fix esm imports in production/transpiled builds 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. --- packages/@uppy/companion/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/@uppy/companion/tsconfig.json b/packages/@uppy/companion/tsconfig.json index 18da726d28..ecce73e0ee 100644 --- a/packages/@uppy/companion/tsconfig.json +++ b/packages/@uppy/companion/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "outDir": "./lib", "module": "commonjs", + "moduleResolution": "node16", "declaration": true, "target": "es6", "noImplicitAny": false,