From 7dcf8c2f36e2638bddd464d0aff3c06893228c9d Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Tue, 11 Jul 2023 15:21:49 +0200 Subject: [PATCH] @uppy/companion: fix esm imports in production/transpiled builds (#4561) 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,