-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
make managerEntries be loaded as ESM, for improved tree-shaking #20070
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -113,11 +119,19 @@ export const resolveAddonName = ( | |||
const managerEntries = []; | |||
|
|||
if (managerFile) { | |||
managerEntries.push(managerFile); | |||
// we remove the extension | |||
// this is a bit of a hack to try en be able to find .mjs files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// this is a bit of a hack to try en be able to find .mjs files | |
// this is a bit of a hack to try to find .mjs files |
} | ||
// register file is the old way of registering addons | ||
if (!managerFile && registerFile && !presetFile) { | ||
managerEntries.push(registerFile); | ||
// we remove the extension | ||
// this is a bit of a hack to try en be able to find .mjs files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// this is a bit of a hack to try en be able to find .mjs files | |
// this is a bit of a hack to try to find .mjs files |
return { | ||
type: 'virtual', | ||
name, | ||
managerEntries: [resolved], | ||
// we remove the extension | ||
// this is a bit of a hack to try en be able to find .mjs files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// this is a bit of a hack to try en be able to find .mjs files | |
// this is a bit of a hack to try to find .mjs files |
arg, github only showed me your review comments after I merged. |
Issue:
I noticed that the whole preview-api is bundled into every manager entry (
manager.mjs
).I was able to assert that this is because the core-server resolves the entry fully. (to prevent pnp issues).
But by resolving it, it resolves the
cjs
entry.What I did
I changed the code in
core-server
so it removes the file extension.Then I configured the manager-builder to try adding
.mjs
to the path.This is not a perfect solution.
A better solution would be to somehow use the exportsMap.
I also configured esbuild to optimize the code.
before:
after: