Closed cre8 closed 5 months ago
It would be much easier to test the migration of a single package to esbuild and to see if it actually improves things.
I suggested the @veramo/utils
package as it is relatively isolated, but still uses tricky dependencies.
It's the dependencies that have caused the most issues for folks.
Despite the fact that esbuild is fast, I am getting a lot of problems when I don't only want it for compilation, but also being interested in the types etc.
I also tried the approach with compiling it with tcs for esm and in parallel with tsc for commonjs. Problem here is to pack both in one npm package. When you add "type": "module"
to the package.json, it is treating all files with an '.js' ending as esm, even when they are in the folder for cjs. So according to the error you need to update the file endings for all files that are commonjs from '.js' to '.cjs'. This is not supported by tsc out of the box. I found some projects, but they seem not to be so stable anymore.
Maybe with a bundler like rollup or babel this could work, but I don't have the time right now to dig deeper.
For building both ESM and CommonJS I would recommend Tsup. I'm not sure if it resolves the issues here, but it is a great tool that solves a lot of issues regarding building/bundling for multiple environments. It is also fast as it uses ESBuild under the hood.
What issue is this PR fixing
fixes #1321
Compared to this PR this is a more cleaner approach to show the current status.
Current problem with ESBUILD:
file:///C:/Users/mollik/Projects/veramo/packages/core-types/build/types/ICredentialStatusManager.js:1 import { DIDDocument, DIDResolutionOptions, DIDResolutionResult } from "did-resolver"; ^^^^^^^^^^^ SyntaxError: The requested module 'did-resolver' does not provide an export named 'DIDDocument' at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21) at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
Node.js v18.17.0
export {}; //# sourceMappingURL=ICredentialStatusManager.js.map
import { DIDDocument, DIDResolutionOptions, DIDResolutionResult } from "did-resolver"; export { DIDDocument, DIDResolutionOptions, DIDResolutionResult }; //# sourceMappingURL=ICredentialStatusManager.js.map