Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@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. This unfortunately breaks in `@types/vfile` which is a transitive dependency of `stylelint-config-rational-order` which has a dependency on an outdated `stylelint` version: ``` yarn why -R @types/vfile └─ @uppy-dev/build@workspace:. └─ stylelint-config-rational-order@npm:0.1.2 (via npm:^0.1.2) └─ stylelint@npm:9.10.1 (via npm:^9.10.1) └─ postcss-markdown@npm:0.36.0 [23902] (via npm:^0.36.0 [23902]) └─ remark@npm:10.0.1 (via npm:^10.0.1) └─ unified@npm:7.1.0 (via npm:^7.0.0) └─ @types/vfile@npm:3.0.2 (via npm:^3.0.0) ``` Newer versions of `stylelint` do not have this dependency anymore, which is why I set the resolution in `package.json`.
- Loading branch information