Problem
When bundling for Node.js, Utoopack resolves dependencies declared in an unreachable AMD branch of a common UMD wrapper.
This affects legacy but still widely used packages such as eventproxy. Its Node.js branch is valid, but the build fails because an AMD-only module does not exist.
Minimal reproduction
Create index.js:
!(function(definition) {
if (typeof define === 'function') {
define([ 'missing-amd-only' ], definition);
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = definition(require('node:path'));
}
})(function(path) {
return path;
});
Use this file as an entry and build it with Utoopack's Node.js target (the same target used by egg-bin bundle).
Actual behavior
The build tries to resolve the AMD dependency and fails:
Module not found: Can't resolve 'missing-amd-only'
The real-world error from eventproxy@1.0.0 is:
./node_modules/eventproxy/lib/eventproxy.js:11:5
Module not found: Can't resolve 'eventproxy_debug'
eventproxy@0.3.5 produces the same error.
Expected behavior
For a Node.js target, typeof define === 'function' is false unless AMD define is explicitly provided. The AMD branch should be eliminated or ignored, and only the CommonJS branch should be resolved.
The example should bundle successfully and retain the node:path dependency without attempting to resolve missing-amd-only.
Context
- Triggered through
egg-bin bundle / @eggjs/egg-bundler
- Utoopack reports the module resolution error
- Updating
eventproxy does not help because 1.0.0 is the latest release and still contains this UMD wrapper
- Forking or patching every legacy UMD dependency would hide the underlying Node-target dead-branch handling issue
It would also be useful to clarify whether Utoopack intends to support AMD dependency arrays inside UMD wrappers, or whether Node-target builds should always treat an unbound define as unavailable.
Problem
When bundling for Node.js, Utoopack resolves dependencies declared in an unreachable AMD branch of a common UMD wrapper.
This affects legacy but still widely used packages such as
eventproxy. Its Node.js branch is valid, but the build fails because an AMD-only module does not exist.Minimal reproduction
Create
index.js:Use this file as an entry and build it with Utoopack's Node.js target (the same target used by
egg-bin bundle).Actual behavior
The build tries to resolve the AMD dependency and fails:
The real-world error from
eventproxy@1.0.0is:eventproxy@0.3.5produces the same error.Expected behavior
For a Node.js target,
typeof define === 'function'is false unless AMDdefineis explicitly provided. The AMD branch should be eliminated or ignored, and only the CommonJS branch should be resolved.The example should bundle successfully and retain the
node:pathdependency without attempting to resolvemissing-amd-only.Context
egg-bin bundle/@eggjs/egg-bundlereventproxydoes not help because1.0.0is the latest release and still contains this UMD wrapperIt would also be useful to clarify whether Utoopack intends to support AMD dependency arrays inside UMD wrappers, or whether Node-target builds should always treat an unbound
defineas unavailable.