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

banner config is unnecessarily transformed in output #719

Closed
lvqq opened this issue Sep 16, 2022 · 4 comments
Closed

banner config is unnecessarily transformed in output #719

lvqq opened this issue Sep 16, 2022 · 4 comments
Labels

Comments

@lvqq
Copy link

lvqq commented Sep 16, 2022

For example, tsup.config.ts like:

export default {
  entry: ['src/index.ts'],
  format: 'esm',
  target: 'esnext',
  banner: {
    js: `import { createRequire } from 'module'; const require = createRequire(import.meta.url);`,
  }
}

Or same option in esbuildOption:

export default {
  entry: ['src/index.ts'],
  format: 'esm',
  target: 'esnext',
  esbuildOptions: (options) => {
    options.banner = {
      js: `import { createRequire } from 'module'; const require = createRequire(import.meta.url);`,
    }
  },
}

Will generate output with:

import { createRequire } from 'module'; const require = createRequire("file://D:\RD\test\tsup-test\tsup.config.ts");

The import.meta.url was totally transformed to the url where tsup.config.ts is.

Expect output:

import { createRequire } from 'module'; const require = createRequire(import.meta.url);
@egoist
Copy link
Owner

egoist commented Nov 3, 2022

try ${'import'}.meta.url instead, it's a naive implementation in https://github.com/egoist/bundle-require to support import.meta.url by simply replacing that string

@egoist
Copy link
Owner

egoist commented Nov 3, 2022

just fixed this in bundle-require, should work without change in the next release: egoist/bundle-require#32

@egoist egoist closed this as completed in 6cbbea1 Nov 3, 2022
@github-actions
Copy link

github-actions bot commented Nov 3, 2022

🎉 This issue has been resolved in version 6.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mahaoming
Copy link

how to fix it ?
image
image

amitdahan pushed a commit to amitdahan/tsup that referenced this issue Dec 25, 2022
catlair added a commit to asunajs/asuna that referenced this issue Mar 18, 2024
catlair added a commit to asunajs/asuna that referenced this issue Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants