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

Support new runtime isJiti and isTsx? #81

Open
1 task
KeJunMao opened this issue Sep 27, 2023 · 2 comments
Open
1 task

Support new runtime isJiti and isTsx? #81

KeJunMao opened this issue Sep 27, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@KeJunMao
Copy link

Describe the feature

I'm developing a vite plugin using unbuild, if it's in stub mode(jiti), inject a package for main.ts using a relative path, otherwise use the package name.

Additional information

  • Would you be willing to help implement this feature?
@pi0 pi0 added the enhancement New feature or request label Sep 27, 2023
@KeJunMao
Copy link
Author

If run directly as a command, I can use process.mainModule.filename to confirm the runtime.

If I use programming to load modules (like the stub mode of unbuild), I don't know how to determine the current runtime.

Currently, I am using the build: done hook of unbouild to output process.env.JITI=true'.

  hooks: {
    'build:done': (ctx) => {
      if (ctx.options.stub) {
        writeFileSync('dist/index.mjs', `process.env.JITI = true;\n${readFileSync('dist/index.mjs', 'utf-8')}`)
      }
    },
  },

@KeJunMao KeJunMao changed the title Support new runtime isJiti and isEsno? Support new runtime isJiti ~isEsno~ and isTsx? Sep 28, 2023
@KeJunMao KeJunMao changed the title Support new runtime isJiti ~isEsno~ and isTsx? Support new runtime isJiti and isTsx? Sep 28, 2023
@pi0
Copy link
Member

pi0 commented Sep 28, 2023

I think we might need to expose such env/static flag from jiti itself to allow detection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants