-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
SignalR npm package not able to be bundled using esbuild
#47674
Comments
Looks like an esbuild issue |
Are you sure? I don't think so, to be honest. This is not about esm / cjs, but instead the workaround which is implemented for webpack here, breaks other bundlers (at least esbuild). To those, the call looks like a dynamic require, although it is actually not dynamic. Do you know, what I mean? |
We are facing the same issue with 5.0.17. The workaround was to replace the __non_webpack_require__ with require using webpack plugin. {
test: /@microsoft.signalr.dist.cjs.(HttpConnection|FetchHttpClient)\.js/,
loader: 'string-replace-loader',
options: {
search: /__non_webpack_require__/g,
replace: 'require',
strict: true
}
} The question I want to ask is why is __non_webpack_require__ is being used because after searching online, it seems like it is not meant to be used in production code and no other package uses it. |
Thanks! |
Unfortunately this issue will need to be reopened. The fix we made broke other important scenarios so we'll need to find a different way to fix this. Starting with 8.0.7 this esbuild issue will start happening again. |
@BrennanConroy did it break multiple scenarios or just the esbuild thing? |
For bundling with replace({
preventAssignment: true,
include: [
'./node_modules/@microsoft/signalr/dist/**/*'
],
values: {
// @microsoft/signalr 8.0.7
'/*#__PURE__*/': '',
'new (requireFunc("tough-cookie")).CookieJar()': 'undefined',
'this._fetchType = requireFunc("fetch-cookie")(this._fetchType, this._jar);': JSON.stringify(''),
'requireFunc("ws")': 'undefined',
'requireFunc("eventsource")': 'undefined'
},
delimiters: ['', '']
}), In addition, the private |
Is there an existing issue for this?
Describe the bug
Hi,
I'm using the npm package
@microsoft/signalr
with version7.0.4
. I'm usingesbuild
for bundeling, however, it does not correctly resolve some dependencies, likews
.This is due those hacks:
I don't think this is an issue of
esbuild
, since it believes that this is a dynamic require. Can we somehow fix this?I confirmed that this is the issue, by patching the lib to use plain
require
instead of therequireFunc
, then everything works correctly.Expected Behavior
ws
is resolved correctly when using thebundle
option ofesbuild
.Steps To Reproduce
https://github.com/hrueger/signalr-esbuild-issue
yarn install
yarn build
__webpack_require__
is still indist/bundle.js
instead of thews
module embedded in the bundle.Exceptions (if any)
No response
.NET Version
n/a
Anything else?
No response
The text was updated successfully, but these errors were encountered: