diff --git a/packages/next-swc-minifier-backport/README.md b/packages/next-swc-minifier-backport/README.md new file mode 100644 index 0000000..1184687 --- /dev/null +++ b/packages/next-swc-minifier-backport/README.md @@ -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 +``` diff --git a/packages/next-swc-minifier-backport/index.js b/packages/next-swc-minifier-backport/index.js new file mode 100644 index 0000000..69d66ef --- /dev/null +++ b/packages/next-swc-minifier-backport/index.js @@ -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)); +}; diff --git a/packages/next-swc-minifier-backport/package.json b/packages/next-swc-minifier-backport/package.json new file mode 100644 index 0000000..8be7651 --- /dev/null +++ b/packages/next-swc-minifier-backport/package.json @@ -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": "강동윤 ", + "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" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aebd13a..168a2f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -160,6 +160,12 @@ importers: specifier: ^4.5.3 version: 4.5.3 + packages/next-swc-minifier-backport: + devDependencies: + '@swc/core': + specifier: ^1.6.4 + version: 1.6.4 + packages/swc-info: devDependencies: '@types/node':