-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create a package for backporting SWC minifier of next.js (#47)
- Loading branch information
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# @swc/next-minifier-backport | ||
|
||
You can install `@swc/next-minifier-backport`, and set the environment variable `NEXT_SWC_MINIFY_BACKPORT` while running `next build`. | ||
|
||
```bash | ||
npm install @swc/next-minifier-backport | ||
``` | ||
|
||
```bash | ||
|
||
NEXT_SWC_MINIFY_BACKPORT=true next build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const swc = require("@swc/core"); | ||
|
||
function patchOptions(options) { | ||
return { | ||
...options, | ||
compress: { | ||
...(options?.compress ?? {}), | ||
inline: 2, | ||
}, | ||
}; | ||
} | ||
|
||
exports.minify = (src, options) => { | ||
return swc.minify(src, patchOptions(options)); | ||
}; | ||
|
||
exports.minifySync = (src, options) => { | ||
return swc.minifySync(src, patchOptions(options)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "@swc/next-minifier-backport", | ||
"version": "0.1.0", | ||
"description": "Backport SWC Minifier without the need to upgrade Next.js", | ||
"main": "index.js", | ||
"scripts": {}, | ||
"keywords": [ | ||
"next.js", | ||
"swc", | ||
"minifier" | ||
], | ||
"author": "강동윤 <kdy1997.dev@gmail.com>", | ||
"bugs": { | ||
"url": "https://github.com/swc-project/pkgs/issues" | ||
}, | ||
"homepage": "https://swc.rs", | ||
"license": "Apache-2.0", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@swc/core": "^1.6.4" | ||
}, | ||
"peerDependencies": { | ||
"@swc/core": "^1.6.4" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.