Skip to content
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

fix(options): CLI option --ignore #204

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
yarn swc editor -d ./build-editor/
checkBuild "editor" "build-editor"

tee spack.config.js <<EOF
tee spack.config.cjs <<EOF
module.exports = {
entry: {
web: __dirname + "/src/Three.js",
Expand All @@ -95,7 +95,7 @@ jobs:
EOF

echo "Run spack"
yarn spack
yarn spack --config ./spack.config.cjs
- name: (swc + spack) rxjs
shell: bash
run: |
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
yarn swc spec -d build-spec
checkBuild "spec" "build-spec"

tee spack.config.js <<EOF
tee spack.config.cjs <<EOF
module.exports = {
entry: {
web: __dirname + "/src/index.ts",
Expand All @@ -165,4 +165,4 @@ jobs:
EOF

echo "Run spack"
yarn spack
yarn spack --config ./spack.config.cjs
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
"source-map": "^0.7.3"
},
"devDependencies": {
"@swc/cli": "^0.1.43",
"@swc/core": "^1.2.66",
"@swc/jest": "^0.1.2",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.44",
"@swc/jest": "^0.2.24",
"@types/jest": "^29.5.0",
"@types/node": "^12.19.16",
"@types/semver": "^7.3.13",
Expand Down
17 changes: 17 additions & 0 deletions src/swc/__tests__/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,21 @@ describe("parserArgs", () => {
expect(result.swcOptions).toEqual(expectedOptions);
});
});

describe("--ignore", () => {
it("includes ignore in cli options", async () => {
const args = [
"node",
"/path/to/node_modules/swc-cli/bin/swc.js",
"src",
"--ignore",
"*.js",
];
expect(parserArgs(args).cliOptions).toEqual(
expect.objectContaining({
ignore: ["*.js"],
})
);
});
});
});
11 changes: 11 additions & 0 deletions src/swc/__tests__/sources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ describe("globSources", () => {

expect([...files]).toEqual(["file"]);
});

it("ignore sources when patterns provided", async () => {
(fs as any).setMockStats({ directory: { isDirectory: () => true } });

(glob as unknown as jest.Mock).mockResolvedValue([]);
await globSources(["directory"], false, ["**/file"]);
expect(glob).toHaveBeenCalledWith(
"directory/**",
expect.objectContaining({ ignore: ["**/file"] })
);
});
});

describe("splitCompilableAndCopyable", () => {
Expand Down
3 changes: 2 additions & 1 deletion src/swc/dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ async function initialCompilation(cliOptions: CliOptions, swcOptions: Options) {
const {
includeDotfiles,
filenames,
ignore,
copyFiles,
extensions,
outDir,
Expand All @@ -109,7 +110,7 @@ async function initialCompilation(cliOptions: CliOptions, swcOptions: Options) {
const results = new Map<string, CompileStatus>();

const start = process.hrtime();
const sourceFiles = await globSources(filenames, includeDotfiles);
const sourceFiles = await globSources(filenames, includeDotfiles, ignore);
const [compilable, copyable] = splitCompilableAndCopyable(
sourceFiles,
extensions,
Expand Down
2 changes: 2 additions & 0 deletions src/swc/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export interface CliOptions {
readonly sourceMapTarget?: string;
readonly filename: string;
readonly filenames: string[];
readonly ignore: string[];
readonly extensions: string[];
readonly watch: boolean;
readonly copyFiles: boolean;
Expand Down Expand Up @@ -261,6 +262,7 @@ export default function parserArgs(args: string[]) {
outFile: opts.outFile,
filename: opts.filename,
filenames,
ignore: opts.ignore,
sync: !!opts.sync,
sourceMapTarget: opts.sourceMapTarget,
extensions: opts.extensions || DEFAULT_EXTENSIONS,
Expand Down
4 changes: 3 additions & 1 deletion src/swc/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import { join, basename, extname } from "path";
*/
export async function globSources(
sources: string[],
includeDotfiles = false
includeDotfiles = false,
ignore: string[] = []
): Promise<string[]> {
const globConfig = {
dot: includeDotfiles,
nodir: true,
ignore,
};

const files = await Promise.all(
Expand Down
173 changes: 103 additions & 70 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,13 @@
slash "^3.0.0"
strip-ansi "^6.0.0"

"@jest/create-cache-key-function@^27.4.2":
version "27.5.1"
resolved "https://registry.yarnpkg.com/@jest/create-cache-key-function/-/create-cache-key-function-27.5.1.tgz#7448fae15602ea95c828f5eceed35c202a820b31"
integrity sha512-dmH1yW+makpTSURTy8VzdUwFnfQh1G8R+DxO2Ho2FFmBbKFEVm+3jWdvFhE2VqB/LATCTokkP0dotjyQyw5/AQ==
dependencies:
"@jest/types" "^27.5.1"

"@jest/environment@^29.5.0":
version "29.5.0"
resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-29.5.0.tgz#9152d56317c1fdb1af389c46640ba74ef0bb4c65"
Expand Down Expand Up @@ -495,6 +502,17 @@
slash "^3.0.0"
write-file-atomic "^4.0.2"

"@jest/types@^27.5.1":
version "27.5.1"
resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.5.1.tgz#3c79ec4a8ba61c170bf937bcf9e98a9df175ec80"
integrity sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==
dependencies:
"@types/istanbul-lib-coverage" "^2.0.0"
"@types/istanbul-reports" "^3.0.0"
"@types/node" "*"
"@types/yargs" "^16.0.0"
chalk "^4.0.0"

"@jest/types@^29.5.0":
version "29.5.0"
resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.5.0.tgz#f59ef9b031ced83047c67032700d8c807d6e1593"
Expand Down Expand Up @@ -606,7 +624,7 @@
dependencies:
"@sinonjs/commons" "^2.0.0"

"@swc/cli@^0.1.43":
"@swc/cli@^0.1.62":
version "0.1.62"
resolved "https://registry.yarnpkg.com/@swc/cli/-/cli-0.1.62.tgz#6442fde2fcf75175a300fb4fcf30f8c60bbb3ab3"
integrity sha512-kOFLjKY3XH1DWLfXL1/B5MizeNorHR8wHKEi92S/Zi9Md/AK17KSqR8MgyRJ6C1fhKHvbBCl8wboyKAFXStkYw==
Expand All @@ -618,76 +636,79 @@
slash "3.0.0"
source-map "^0.7.3"

"@swc/[email protected].41":
version "1.3.41"
resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.41.tgz#c8ec25fb3171e1e53546d0fbf4044c33d5ab42c5"
integrity sha512-D4fybODToO/BvuP35bionDUrSuTVVr8eW+mApr1unOqb3mfiqOrVv0VP2fpWNRYiA+xMq+oBCB6KcGpL60HKWQ==

"@swc/[email protected].41":
version "1.3.41"
resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.3.41.tgz#0f9d7077762f4274d50a8ef76a56b76096a8f0ff"
integrity sha512-0RoVyiPCnylf3TG77C3S86PRSmaq+SaYB4VDLJFz3qcEHz1pfP0LhyskhgX4wjQV1mveDzFEn1BVAuo0eOMwZA==

"@swc/[email protected].41":
version "1.3.41"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.41.tgz#5f6a03c4e8cae674b6262fc0d625379af14985be"
integrity sha512-mZW7GeY7Uw1nkKoWpx898ou20oCSt8MR+jAVuAhMjX+G4Zr0WWXYSigWNiRymhR6Q9KhyvoFpMckguSvYWmXsw==

"@swc/[email protected].41":
version "1.3.41"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.41.tgz#e1c0a1669873dbab9ecb9573c2f7dd81b764212e"
integrity sha512-e91LGn+6KuLFw3sWk5swwGc/dP4tXs0mg3HrhjImRoofU02Bb9aHcj5zgrSO8ZByvDtm/Knn16h1ojxIMOFaxg==

"@swc/[email protected].41":
version "1.3.41"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.41.tgz#add780ae831a72a65ec799009d0c0e3e78bb969c"
integrity sha512-Q7hmrniLWsQ7zjtImGcjx1tl5/Qxpel+fC+OXTnGvAyyoGssSftIBlXMnqVLteL78zhxIPAzi+gizWAe5RGqrA==

"@swc/[email protected].41":
version "1.3.41"
resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.41.tgz#5b2bf83493e6fa0a58c3fb1815b9e59b923e300f"
integrity sha512-h4sv1sCfZQgRIwmykz8WPqVpbvHb13Qm3SsrbOudhAp2MuzpWzsgMP5hAEpdCP/nWreiCz3aoM6L8JeakRDq0g==

"@swc/[email protected].41":
version "1.3.41"
resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.41.tgz#146547ea3e62466ca971d71ebcc4cfeed3008bda"
integrity sha512-Z7c26i38378d0NT/dcz8qPSAXm41lqhNzykdhKhI+95mA9m4pskP18T/0I45rmyx1ywifypu+Ip+SXmKeVSPgQ==

"@swc/[email protected].41":
version "1.3.41"
resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.41.tgz#91e438c1ca102b52172294905821b43f9d429a32"
integrity sha512-I0CYnPc+ZGc912YeN0TykIOf/Q7yJQHRwDuhewwD6RkbiSEaVfSux5pAmmdoKw2aGMSq+cwLmgPe9HYLRNz+4w==

"@swc/[email protected].41":
version "1.3.41"
resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.41.tgz#77bdb6ab0ae942039756d41300c47315357bd814"
integrity sha512-EygN4CVDWF29/U2T5fXGfWyLvRbMd2hiUgkciAl7zHuyJ6nKl+kpodqV2A0Wd4sFtSNedU0gQEBEXEe7cqvmsA==

"@swc/[email protected].41":
version "1.3.41"
resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.41.tgz#a8d766fc7a68752a3060276a90b7328d9f266631"
integrity sha512-Mfp8qD1hNwWWRy0ISdwQJu1g0UYoVTtuQlO0z3aGbXqL51ew9e56+8j3M1U9i95lXFyWkARgjDCcKkQi+WezyA==

"@swc/core@^1.2.66":
version "1.3.41"
resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.3.41.tgz#8f10559db269da1a5df9863c92653f8afd0bd7c1"
integrity sha512-v6P2dfqJDpZ/7RXPvWge9oI6YgolDM0jtNhQZ2qdXrLBzaWQdDoBGBTJ8KN/nTgGhX3IkNvSB1fafXQ+nVnqAQ==
"@swc/[email protected].44":
version "1.3.44"
resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.44.tgz#e0f5eb9d962c4e6192531c2e3b8c11f55faf1b89"
integrity sha512-Y+oVsCjXUPvr3D9YLuB1gjP84TseM/CRkbPNrf+3JXQhsPEkgxdIdFP1cl/obeqMQrRgPpvSfK+TOvGuOuV22g==

"@swc/[email protected].44":
version "1.3.44"
resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.3.44.tgz#a8de4c176a9b12f201fc754a56331113a53ec69c"
integrity sha512-bM0IKBjlSD0yHJbd7bE3il5fTu3oUjUO2zjLkzfIx6tiqbmDyvOX8adaSqse9N+d8Ip9p26b5Vo7pMHq0POGkg==

"@swc/[email protected].44":
version "1.3.44"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.44.tgz#300731367c88bf02b8ae20264d4d402362e444df"
integrity sha512-D4lfVwCbkWscDTb6btb89+bN0kgvjGBPfOmcvih7nY5hxaorwvp+PefkYAhFw8vKmL92lrnWUFNiTemVFN4bxg==

"@swc/[email protected].44":
version "1.3.44"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.44.tgz#8b52d1cd28f277d47bb45c6791f44da568a62bc4"
integrity sha512-muExPTrN26MFmtO+5uffkH5v4lmd8GdmyWvlC2tL95h7o9genTIQyr7kcSepGZrDe4fM9G6++5YfENhUpXHo+g==

"@swc/[email protected].44":
version "1.3.44"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.44.tgz#7b0e62255ae13c397f09ca5da8bf2266482a28c2"
integrity sha512-MY1wY3kSIosjJKKCfFGniJFFVkt3oPvJLN4Dlj+bMgAt3O7anm8lGbyLqUpJ1Ep4rTsJj7ObO06DQiSWp4Fhcw==

"@swc/[email protected].44":
version "1.3.44"
resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.44.tgz#0b8b2544c312f247aa5c5f31671a175ad6488309"
integrity sha512-xV4pDxJM06g0yUDTA22ZHgonzGqf/poIlgADRmEkx9cWWm5qLRhmWrrkVX1xZVvdlcXj1ERnia/UkvrDux96lg==

"@swc/[email protected].44":
version "1.3.44"
resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.44.tgz#5b1f76fc1dc75875df59d8c0ff37e99e030f9552"
integrity sha512-NJnnlE8vCkKHoo/wIaoywNN/01vNsvhKUjBgUx865sUM/XWAIanpbV41yfdEkC+Iwd+/zB3ZZnOYql3b+Nn8aQ==

"@swc/[email protected].44":
version "1.3.44"
resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.44.tgz#bd4aefcd7734229f780c9bec0502935884935f0f"
integrity sha512-/xOtjZhX25GEOPLN55icjj9E061DDH7G0A9HfUAEilURgBbvm6bIlqK+t8mOKK0tOsDoHftdTBRkYhTAqUtakQ==

"@swc/[email protected].44":
version "1.3.44"
resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.44.tgz#0c2ba768f33acb580422e17d4ae816ebfd3dcfe0"
integrity sha512-uKTAWQuMEW1gJnl8F3eiz3kdk8CiaR5dMWWlGbHIq6dRbur2hoKaEnINR4UqkvvAhhY1YB0Xr5DV1H986Xu2EA==

"@swc/[email protected].44":
version "1.3.44"
resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.44.tgz#b137abefbeb3b73a47cc398bc5603ea6bf6a3a7b"
integrity sha512-D9fBRhr44cK4YIKFikpktyUDLkZgVj0ISaSl8IjiTvjqTrE/9+E+dzTNHULn5tc3lHVLLxyVwMjJRr2G0D4O6w==

"@swc/core@^1.3.44":
version "1.3.44"
resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.3.44.tgz#2886bdd647942f9670b65c02b6d5484ff3070ddd"
integrity sha512-RC25C8nxOCdfGS//F9Q8aHKx4XoCsxvgO+sSUhvt7zDz1Y2ruVUTu2UOH0VeE0WkA8j6oEZH+xH2SUfDUkxXdA==
optionalDependencies:
"@swc/core-darwin-arm64" "1.3.41"
"@swc/core-darwin-x64" "1.3.41"
"@swc/core-linux-arm-gnueabihf" "1.3.41"
"@swc/core-linux-arm64-gnu" "1.3.41"
"@swc/core-linux-arm64-musl" "1.3.41"
"@swc/core-linux-x64-gnu" "1.3.41"
"@swc/core-linux-x64-musl" "1.3.41"
"@swc/core-win32-arm64-msvc" "1.3.41"
"@swc/core-win32-ia32-msvc" "1.3.41"
"@swc/core-win32-x64-msvc" "1.3.41"

"@swc/jest@^0.1.2":
version "0.1.5"
resolved "https://registry.yarnpkg.com/@swc/jest/-/jest-0.1.5.tgz#102e0cd5e82aee8af2df633fcd3b4bcedb42ec1a"
integrity sha512-PKKaJ5wqjkpmqQjGVbZxsXn5bIFCToqS1RHg5RbZzLnBL0eOIg8cD3SsnW9d5+im8L6QAWl6pETLZE2QFYSrFA==
"@swc/core-darwin-arm64" "1.3.44"
"@swc/core-darwin-x64" "1.3.44"
"@swc/core-linux-arm-gnueabihf" "1.3.44"
"@swc/core-linux-arm64-gnu" "1.3.44"
"@swc/core-linux-arm64-musl" "1.3.44"
"@swc/core-linux-x64-gnu" "1.3.44"
"@swc/core-linux-x64-musl" "1.3.44"
"@swc/core-win32-arm64-msvc" "1.3.44"
"@swc/core-win32-ia32-msvc" "1.3.44"
"@swc/core-win32-x64-msvc" "1.3.44"

"@swc/jest@^0.2.24":
version "0.2.24"
resolved "https://registry.yarnpkg.com/@swc/jest/-/jest-0.2.24.tgz#35d9377ede049613cd5fdd6c24af2b8dcf622875"
integrity sha512-fwgxQbM1wXzyKzl1+IW0aGrRvAA8k0Y3NxFhKigbPjOJ4mCKnWEcNX9HQS3gshflcxq8YKhadabGUVfdwjCr6Q==
dependencies:
"@jest/create-cache-key-function" "^27.4.2"
jsonc-parser "^3.2.0"

"@szmarczak/http-timer@^4.0.5":
version "4.0.6"
Expand Down Expand Up @@ -827,6 +848,13 @@
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.0.tgz#0c60e537fa790f5f9472ed2776c2b71ec117351b"
integrity sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==

"@types/yargs@^16.0.0":
version "16.0.5"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-16.0.5.tgz#12cc86393985735a283e387936398c2f9e5f88e3"
integrity sha512-AxO/ADJOBFJScHbWhq2xAhlWP24rY4aCEG/NFaMvbT3X2MgRsLjhjQwsn0Zi5zn0LG9jUhCCZMeX9Dkuw6k+vQ==
dependencies:
"@types/yargs-parser" "*"

"@types/yargs@^17.0.8":
version "17.0.22"
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.22.tgz#7dd37697691b5f17d020f3c63e7a45971ff71e9a"
Expand Down Expand Up @@ -2104,6 +2132,11 @@ json5@^2.2.2, json5@^2.2.3:
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

jsonc-parser@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz#31ff3f4c2b9793f89c67212627c51c6394f88e76"
integrity sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==

keyv@^4.0.0:
version "4.5.2"
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.2.tgz#0e310ce73bf7851ec702f2eaf46ec4e3805cce56"
Expand Down