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

feat: Merge @swc/jest into the monorepo #10

Merged
merged 23 commits into from
Feb 1, 2024
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4

[*.yml]
indent_size = 2
37 changes: 37 additions & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Configure Node.js"
description: "Sets Node.js up for CI"
inputs:
node-version:
description: "Node version to install"
required: false
default: "18"

runs:
using: "composite"
steps:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}

- uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
shell: bash
run: pnpm install
62 changes: 62 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI

on:
push:
branches: ["main"]
pull_request:
types: [opened, synchronize]
merge_group:

env:
CI: 1

jobs:
test:
name: Test
timeout-minutes: 15
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16, 18, 20]

steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ matrix.node-version }}

- name: Test
run: pnpm test

lint:
name: Lint
timeout-minutes: 15
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: 20

- name: Test
run: pnpm lint

ci-done:
name: Ok
needs:
- test
- lint
if: always()
runs-on: ubuntu-latest
steps:
- run: exit 1
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled')) }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,6 @@ dist
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.pnp.*

.DS_Store
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# @swc/pkgs

Various npm packages for the SWC project.

- [swc-loader](./packages/swc-loader): A webpack loader for swc.
- [@swc/jest](./packages/jest): A jest transformer for swc.
82 changes: 44 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
{
"name": "swc-extra-packages-workspace",
"packageManager": "pnpm@8.6.7",
"private": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/swc"
},
"scripts": {
"prepare": "husky install && git config feature.manyFiles true"
},
"lint-staged": {
"*.toml": [
"taplo format"
],
"*.rs": [
"rustfmt --"
],
"!(**/tests/**/*)*.js": [
"prettier --write"
],
"!(**/tests/**/*)*.ts": [
"prettier --write"
],
"!(**/tests/**/*)*.jsx": [
"prettier --write"
],
"!(**/tests/**/*)*.tsx": [
"prettier --write"
]
},
"devDependencies": {
"@taplo/cli": "^0.5.2",
"cross-env": "^7.0.3",
"cspell": "^6.31.1",
"husky": "^8.0.3",
"lint-staged": "^13.2.3",
"prettier": "^2"
}
"name": "swc-extra-packages-workspace",
"packageManager": "pnpm@8.6.7",
"private": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/swc"
},
"scripts": {
"prepare": "husky install && git config feature.manyFiles true",
"test": "turbo test",
"lint": "turbo lint"
},
"lint-staged": {
"*.toml": [
"taplo format"
],
"*.rs": [
"rustfmt --"
],
"!(**/tests/**/*)*.js": [
"prettier --write"
],
"!(**/tests/**/*)*.ts": [
"prettier --write"
],
"!(**/tests/**/*)*.jsx": [
"prettier --write"
],
"!(**/tests/**/*)*.tsx": [
"prettier --write"
],
"**": [
"prettier --write --ignore-unknown"
]
},
"devDependencies": {
"@taplo/cli": "^0.5.2",
"cross-env": "^7.0.3",
"cspell": "^6.31.1",
"husky": "^8.0.3",
"lint-staged": "^13.2.3",
"prettier": "^2",
"turbo": "^1.10.7"
}
}
3 changes: 1 addition & 2 deletions packages/css-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"license": "APACHE-2.0",
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"test": "jest"
"build": "tsc"
},
"keywords": [],
"devDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions packages/jest/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
examples
**/*.js
13 changes: 13 additions & 0 deletions packages/jest/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
127 changes: 127 additions & 0 deletions packages/jest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

.idea

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*


yarn.lock


/*.js
*.d.ts

.DS_Store
25 changes: 25 additions & 0 deletions packages/jest/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) 2021 The swc Project Developers

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Loading
Loading