How to get minify code?
See original GitHub issueI want get minify code after build , and my unbuild config this:
import { defineBuildConfig } from "unbuild";
export default defineBuildConfig({
entries: ["./index"],
declaration: true,
clean: true,
failOnWarn: false,
rollup: {
emitCJS: true,
esbuild: {
minify: true
}
}
});
But after pnpm build
, I get this error:
Error building E:/project/changan-incall/packages/microApp: Error: Transform failed with 1 error:
<stdin>:1:10: ERROR: Expected ";" but found "EnterMicroAppParams"
Error: Transform failed with 1 error:
<stdin>:1:10: ERROR: Expected ";" but found "EnterMicroAppParams"
at failureErrorWithLog (E:\project\changan-incall\node_modules\.pnpm\esbuild@0.15.6\node_modules\esbuild\lib\main.js:1624:15)
at E:\project\changan-incall\node_modules\.pnpm\esbuild@0.15.6\node_modules\esbuild\lib\main.js:1413:29
at E:\project\changan-incall\node_modules\.pnpm\esbuild@0.15.6\node_modules\esbuild\lib\main.js:678:9
at handleIncomingPacket (E:\project\changan-incall\node_modules\.pnpm\esbuild@0.15.6\node_modules\esbuild\lib\main.js:775:9)
at Socket.readFromStdout (E:\project\changan-incall\node_modules\.pnpm\esbuild@0.15.6\node_modules\esbuild\lib\main.js:644:7)
at Socket.emit (node:events:526:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) {
errors: [
{
detail: undefined,
id: '',
location: [Object],
notes: [],
pluginName: '',
text: 'Expected ";" but found "EnterMicroAppParams"'
}
],
warnings: [],
code: 'PLUGIN_ERROR',
plugin: 'esbuild',
hook: 'renderChunk'
}
How Can I resolve this ? Hope get you help genuine.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to Minify JavaScript — Recommended Tools and Methods
To minify JavaScript code, you must parse it, compress it, and get the output. Once it's been minified, it should be almost unreadable...
Read more >Minify - JavaScript and CSS minifier
Make your website smaller and faster to load by minifying the JS and CSS code. ... This minifier removes whitespace, strips comments, combines...
Read more >How to 'minify' Javascript code - Stack Overflow
Install it and reload VSCode. Then click on your file, open command palette ( Ctrl+Shift+p ), ant type minify this document ( Ctrl+alt+m...
Read more >Minify Resources (HTML, CSS, and JavaScript)
To minify HTML, try HTMLMinifier ; To minify CSS, try CSSNano and csso. ; To minify JavaScript, try UglifyJS. The Closure Compiler is...
Read more >How to Minify JavaScript & CSS? - Code Institute Global
Upload the source code file or paste your source code. · Set the parameters for a particular output. · To minify or compress...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I submitted a quick PR that should fix this issue: https://github.com/unjs/unbuild/pull/185
I guess @Phl3bas is correct.
rollup-plugin-dts
doesn’t seem to work well with the esbuild plugin used in unbuild. For what I can understand, the esbuild plugin tries to load and minify.d.ts
file chunks generated by thedts
plugin with thejs
loader (source) which causes an error because the generated TS definition is not valid JavaScript:unbuild runs two rollup builds, one to transform the source to JS and one (optional) to generate the TS definitions. I managed to fix the issue using the
rollup:dts:options
hook which receives the option passed to the TS definitions build:This is more of a hack than a workaround, so I guess we should fix the issue with a PR.