-
Notifications
You must be signed in to change notification settings - Fork 1.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
logform library uses non-string literals in require and fails at runtime, but works with webpack #480
Comments
I believe Webpack does this by bundling all files reachable in that directory and all nested directories, which ends up unintentionally including extra stuff in the bundle in this case. I think this is kind of an anti-pattern and I'm not currently planning on including this ability in esbuild. This code in logform can easily be replaced by bare Webpack has a ton of features both because it's by far the majority bundler and because it's had many years of many contributors adding features. It's not a goal of esbuild to replicate all of Webpack's features, so just because Webpack supports this doesn't necessarily mean esbuild should too, especially if the feature isn't trivial and has negative implications for bundle size. |
Makes sense. Unfortunately I don't have influence over |
You could hop-over the logform/index.js file entirely by creating your own local version of that index file which points to its dependencies. I've made a repo as an example: https://github.com/heyheyhello/esbuild-logform-example https://github.com/heyheyhello/esbuild-logform-example/blob/work/index.js#L1-L16 https://github.com/heyheyhello/esbuild-logform-example/blob/work/logform.js#L1-L22 Basically everywhere in your project that you import "logform" now import "./logform" (or setup a non-relative path in your tsconfig.json/jsconfig.json since esbuild will follow that) |
Hmm, that seems a bit involved. Would the |
Since esbuild respects {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"logform": [
"./custom-logform.js"
]
}
}
} Where (click to expand
|
Closing since there is an esbuild-specific workaround and the authors of that package are aware of the problem and have been provided with a fix. |
Importing from paths generated at runtime breaks parcel, see (parcel-bundler/parcel#4031), or esbuild, see (evanw/esbuild#480) By removing the calls to the deprecated global MONGOOSE_DRIVER_PATH this issue can be resolved.
Importing from paths generated at runtime breaks parcel, see (parcel-bundler/parcel#4031), or esbuild, see (evanw/esbuild#480) By removing the calls to the deprecated global MONGOOSE_DRIVER_PATH this issue can be resolved.
Hit the same issue, 😞 trying to follow @evanw 's suggestion about using a custom logform.js file, but hitting the below error during
|
The npm library logform does this:
The value of
path
is pretty "static" for a list of local modules.Running this with
esbuild
results in this warning:But at runtime usage of the logform module fails with e.g.
While I understand that non-string literals are skipped, this actually works fine with webpack (using version 4). So they must have a trick for such a "simple" case that maybe
esbuild
could replicate.The text was updated successfully, but these errors were encountered: