-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Library mode umd build hangs #14065
Comments
Start a new pull request in StackBlitz Codeflow. |
I think I've found a minimal reproduction similar to the #7188 issue: When the // foo.ts
export const foo = { ...{} }; // index.ts
export * from './foo';
foo()?.bar; will cause the output to contain helpers injected to the global scope var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.Test = {}));
})(this, function(exports2) {
var _a;
"use strict";
const foo$1 = __spreadValues({}, {});
(_a = foo()) == null ? void 0 : _a.bar;
exports2.foo = foo$1;
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
}); However, commenting out either of the lines will prevent the helpers to become global. Maybe this could help to discovering a better fix to #7188 |
Describe the bug
We have a rather large library (~9MB mininized) being converted from webpack to vite. The esm format builds just fine, but umd builds hangs for ~7 minutes. After searching a bit I found the same issue #10900 and doing profiling myself revealed the same offending regex
const INJECT_HELPERS_UMD_RE =
I can't share the code, but the closest I got is getting a repo in library mode with as much bundled code as possible - though it didn't hang for that long.
Looking at the #7948 that fixed the collision issue, maybe we should find another fix that configures esbuild properly so that no regex replacement is required?
Reproduction
https://stackblitz.com/edit/vitejs-vite-bpuk79?file=index.ts
Steps to reproduce
npm run build
^(.*?)(\(function\([^)]*\)\s*\{.+?amd.+?function\([^)]*\)\s*\{\s*"use strict";)
System Info
System: OS: macOS 13.4.1 CPU: (10) arm64 Apple M1 Pro Memory: 170.47 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.13.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.19.3 - /usr/local/bin/npm pnpm: 8.6.2 - /usr/local/bin/pnpm Browsers: Chrome: 115.0.5790.170 Safari: 16.5.2 npmPackages: vite: ^4.4.9 => 4.4.9
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: