mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 09:38:16 +03:00
chore(es/minifier): Add a script to copy tests from a next.js app (#2778)
This commit is contained in:
parent
8c04d396e4
commit
e1b76654f5
@ -16,6 +16,7 @@
|
||||
"devDependencies": {
|
||||
"antd": "^4.16.13",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"eslint": "^7.29.0"
|
||||
"eslint": "^7.29.0",
|
||||
"readline": "^1.3.0"
|
||||
}
|
||||
}
|
||||
|
14
crates/swc_ecma_minifier/scripts/next/add-test.sh
Executable file
14
crates/swc_ecma_minifier/scripts/next/add-test.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
|
||||
# Usage: Invoke this script using full path from a next app.
|
||||
|
||||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
export NEXT_DEBUG_MINIFY=1
|
||||
|
||||
# Remove preovious builds
|
||||
rm -r .next
|
||||
|
||||
|
||||
npx next build | grep '{ name:' | node "$SCRIPT_DIR/evaluate.js"
|
24
crates/swc_ecma_minifier/scripts/next/evaluate.js
Normal file
24
crates/swc_ecma_minifier/scripts/next/evaluate.js
Normal file
@ -0,0 +1,24 @@
|
||||
const readline = require('readline');
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
terminal: false
|
||||
});
|
||||
|
||||
rl.on('line', async (data) => {
|
||||
try {
|
||||
const { name, source } = eval(`(${data})`)
|
||||
const targetPath = path.join(__dirname, '..', '..', 'tests', 'compress', 'fixture', 'issues', 'next', name);
|
||||
|
||||
await fs.mkdir(path.dirname(targetPath), { recursive: true });
|
||||
|
||||
await fs.writeFile(targetPath, source, 'utf8');
|
||||
} catch (e) {
|
||||
console.log(`Code: (${data})`)
|
||||
console.error(e);
|
||||
}
|
||||
})
|
||||
|
@ -1243,6 +1243,11 @@ react-is@^16.12.0:
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
|
||||
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
|
||||
|
||||
readline@^1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/readline/-/readline-1.3.0.tgz#c580d77ef2cfc8752b132498060dc9793a7ac01c"
|
||||
integrity sha1-xYDXfvLPyHUrEySYBg3JeTp6wBw=
|
||||
|
||||
regenerator-runtime@^0.13.4:
|
||||
version "0.13.9"
|
||||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"
|
||||
|
Loading…
Reference in New Issue
Block a user