-
Notifications
You must be signed in to change notification settings - Fork 486
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
@rspack/dev-middleware defalut export will cause node esm envirment crash. #2944
Comments
we should use |
we can't export more types or variables if we use |
Hm, can you use this? function getRspackMemoryAssets(...args) {
// Code
}
getRspackMemoryAssets.something = 1;
export default getRspackMemoryAssets; |
this will work for variable but not for tyoe |
But for types you can use I don't understand the problem a bit, maybe I'm missing something? |
currently we use "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = rdm; but since nodejs doesn't recognize import rdm from '@rspack/dev-middleware' // rdm is { default: rdm} which is very weird so we have two choices here
then
which works perfectly on
|
@hardfist I see, but
What do you want to export here and why |
yes |
@hardfist What about this: function rdm() {}
namespace rdm {
export type RdmMiddlelWare = {
name: "xxx";
};
}
export = rdm; |
That is old CommonJs approach to do it 😄 |
this is too hacky for me 😭, I'm gonna choose the simplest way 😁 |
even it's kind of hacky, I buy into this way now 🤣 |
It is not hacky, it is official way for CommonJS 😄 One day we will migrate on ESM |
System Info
Details
The middleware use
default
to export value, but when the import file is.mjs
, the export value is object which has default value.Reproduce link
No response
Reproduce Steps
The text was updated successfully, but these errors were encountered: