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

[Bug]: require.resolve was compiled incorrectly #401

Open
chenjiahan opened this issue Nov 11, 2024 · 1 comment
Open

[Bug]: require.resolve was compiled incorrectly #401

chenjiahan opened this issue Nov 11, 2024 · 1 comment
Assignees
Labels
🐞 bug Something isn't working

Comments

@chenjiahan
Copy link
Member

Version

Rslib 0.0.16

Details

  • Input:
// index.ts
import { require } from './require';

console.log(require.resolve('@rslib/core'));

// require.ts
import { createRequire } from 'module';

export const require = createRequire(import.meta.url);
  • Output:
import * as __WEBPACK_EXTERNAL_MODULE_module__ from "module";
const require_require = (0, __WEBPACK_EXTERNAL_MODULE_module__.createRequire)(import.meta.url);
console.log(require_require('@rslib/core'));
  • Expected output:
import * as __WEBPACK_EXTERNAL_MODULE_module__ from "module";
const require_require = (0, __WEBPACK_EXTERNAL_MODULE_module__.createRequire)(import.meta.url);
- console.log(require_require('@rslib/core'));
+ console.log(require_require.resolve('@rslib/core'));

Reproduce link

https://github.com/chenjiahan/rslib-repro-esm-require-resolve

Reproduce Steps

  1. pnpm i
  2. pnpm build
@chenjiahan chenjiahan added the 🐞 bug Something isn't working label Nov 11, 2024
@fi3ework fi3ework self-assigned this Nov 11, 2024
@fi3ework
Copy link
Member

Seems like a parsing issue with Rspack initially.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants