-
-
Notifications
You must be signed in to change notification settings - Fork 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
The code published to npm is minified #4065
Comments
The main goal of us doing so has been to
I do see what you are saying about traces becoming unreadable while investigating bugs/performance. It's been one of my main motivators to fight for "readable" dist bundles as well. However doing so would most likely warrant a major as we do ship properties that we need mangled for our plugin ecosystem, the reconciler is pluggable so devtools/signals/fast-refresh rely on that being consistent. If you are facing a bug and don't know how to reproduce due to the bundle being unreadable I am open to figure this out together on a GitHub discussion/... |
For my personal use case I am likely to copy paste the source code of I ran into the same issue with It would help me if you committed a version of The way i used to copy jquery.js into my |
I guess having This would be a non breaking change, just an extra file into the npm publish tarball. |
As Jovi mentioned, this could be an issue as the plugin system relies upon mangled properties for hooking into the reconciler. If you're only using Preact core, you shouldn't run into any issues, but you are locking yourself off from devtools/prefresh/etc. Unfortunately I'm not sure a mangled, but unminified, distribution file would end up being much more readable... |
I appreciate the technical explanation of why this wouldn't work with the ecosystem and the devtools. I am however completely blown away that this technical limitation exists. it boggles my mind. A mangled & unminified build would not really be helpful. I guess all the plugin ecosystem tools would have to support both mangled & unmangled copy of preact with some kind of config setting. |
Well, I'm not quite sure what other alternatives exist. The problem is that properties need to remain consistent across versions and across every distribution method. A few CDNs mangle themselves (whether they should is another issue) and bundlers may need some config to ensure both Preact & the add-on have consistently mangled properties. Mangling ahead of time certainly isn't ideal, but I don't know of any better options that doesn't offload the problem onto end users. |
The consistent mangling for ecosystem I can understand. Would be nice if the ecosystem respects both the unmangled and mangled property names, so I could use either the min or raw version. |
Is there a way to import the source version? I'm currently using: I tried this: |
As mentioned, no.
You'd need to configure your TS plugin to compile |
I was able to get a PoC working with esbuild by: Tweaking
"./src": {
"types": "./src/index.d.ts",
"browser": "./src/index.js",
"import": "./src/index.js"
},
"./jsx-dev-runtime": {
"types": "./jsx-runtime/src/index.d.ts",
"browser": "./jsx-runtime/src/index.js",
"import": "./jsx-runtime/src/index.js"
}, Currently Then you adjust the alias settings in esbuild for development: Alias: map[string]string{
"preact": "preact/src",
"preact/jsx-runtime": "preact/jsx-dev-runtime",
}, I'd be open to submitting a PR if this is something the Preact team would consider! |
I would +1 this as somewhere in between I'm currently exploring something like this in const preactSrcResolvePlugin = {
name: 'preactSrcResolve',
setup(build) {
build.onResolve({ filter: /preact/ }, args => {
const basePath = `${__dirname}/node_modules/preact`;
if (args.path == 'preact') {
return { path: `${basePath}/src/index.js` }
} else if(args.path == 'preact/hooks') {
return { path: `${basePath}/hooks/src/index.js` }
}
})
},
} |
Since the code in the npm tarball is minified by default ( https://socket.dev/npm/package/preact/files/10.15.1/dist/preact.mjs )
It's nearly impossible to debug or profile the preact framework when using it to build my app.
Please do not publish minified code and let me run my own minifier.
The text was updated successfully, but these errors were encountered: