Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic require of "child_process" is not supported #1079

Closed
anchan828 opened this issue Sep 22, 2024 · 3 comments · Fixed by #1086
Closed

Dynamic require of "child_process" is not supported #1079

anchan828 opened this issue Sep 22, 2024 · 3 comments · Fixed by #1086
Labels
bug 🔥 Something isn't working prioritized 🚚 This issue has been prioritized and will be worked on soon

Comments

@anchan828
Copy link
Contributor

anchan828 commented Sep 22, 2024

Description

An error occurs when the createClient API of ESM is called.

This change will probably solve the problem, but I'm not sure if it's a good solution.

packages/openapi-ts/tsup.config.ts

export default defineConfig((options) => ({
+  banner(ctx) {
+    if(ctx.format === 'esm') {
+      return {
+        js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);"
+      }
+    }
+  },
  clean: true,
  dts: true,
  entry: ['src/index.ts'],
  format: ['cjs', 'esm'],
  minify: !options.watch,
  shims: false,
  sourcemap: true,
  treeshake: true,
}));

evanw/esbuild#1921 (comment)

Reproducible example or configuration

An error occurs when tsx build.ts is called. Since the command is set in startCommand, an error should be output as soon as the browser is opened.
https://stackblitz.com/edit/hey-api-example-dbtez4?file=build.ts

OpenAPI specification (optional)

No response

System information (optional)

{
  "@hey-api/client-fetch": "0.3.2",
  "@hey-api/openapi-ts": "0.53.3"
}
@anchan828 anchan828 added the bug 🔥 Something isn't working label Sep 22, 2024
Copy link

stackblitz bot commented Sep 22, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@mrlubos mrlubos added the prioritized 🚚 This issue has been prioritized and will be worked on soon label Sep 22, 2024
@mrlubos
Copy link
Member

mrlubos commented Sep 22, 2024

@anchan828 Huh, that's exactly what this was supposed to be fixing. Thanks for reporting, I'll have a look

@mrlubos
Copy link
Member

mrlubos commented Sep 25, 2024

I like this fix a lot, simplifies the messy code a great deal, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working prioritized 🚚 This issue has been prioritized and will be worked on soon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants