Skip to content

Commit

Permalink
feat(nx-set-shas): compiled using swc
Browse files Browse the repository at this point in the history
  • Loading branch information
gperdomor committed Jul 13, 2024
1 parent aab5a1a commit e0783e5
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 7 deletions.
5 changes: 5 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
},
"nxCloudAccessToken": "YTA4ZDcwNjQtMDZmNC00YjUyLTk5ZTMtN2E1ZDE1ZTkwMWYxfHJlYWQ=",
"targetDefaults": {
"@nx/js:swc": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"@nx/js:tsc": {
"cache": true,
"dependsOn": ["^build"],
Expand Down
35 changes: 34 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@nx/devkit": "19.4.3",
"@octokit/openapi-types": "22.1.0",
"@renovate/pep440": "1.0.0",
"@swc/helpers": "0.5.11",
"chalk": "4.1.2",
"ci-info": "4.0.0",
"clipanion": "4.0.0-rc.3",
Expand Down Expand Up @@ -48,6 +47,8 @@
"@swc-node/register": "1.9.2",
"@swc/cli": "0.3.12",
"@swc/core": "1.5.7",
"@swc/helpers": "~0.5.11",
"@swc/jest": "~0.2.36",
"@types/jest": "29.5.6",
"@types/node": "18.19.31",
"@types/semver": "7.5.8",
Expand Down
29 changes: 29 additions & 0 deletions packages/nx-set-shas/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"jsc": {
"target": "es2021",
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true
},
"keepClassNames": true,
"externalHelpers": true,
"loose": true
},
"module": {
"type": "commonjs"
},
"sourceMaps": true,
"exclude": [
"jest.config.ts",
".*\\.spec.tsx?$",
".*\\.test.tsx?$",
"./src/jest-setup.ts$",
"./**/jest-setup.ts$",
".*.js$"
]
}
19 changes: 18 additions & 1 deletion packages/nx-set-shas/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
/* eslint-disable */
import { readFileSync } from 'fs';

// Reading the SWC compilation config and remove the "exclude"
// for the test files to be compiled by SWC
const { exclude: _, ...swcJestConfig } = JSON.parse(readFileSync(`${__dirname}/.swcrc`, 'utf-8'));

// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves.
// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude"
if (swcJestConfig.swcrc === undefined) {
swcJestConfig.swcrc = false;
}

// Uncomment if using global setup/teardown files being transformed via swc
// https://nx.dev/nx-api/jest/documents/overview#global-setupteardown-with-nx-libraries
// jest needs EsModule Interop to find the default exported setup/teardown functions
// swcJestConfig.module.noInterop = false;

export default {
displayName: 'nx-set-shas',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/nx-set-shas',
Expand Down
6 changes: 3 additions & 3 deletions packages/nx-set-shas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
},
"dependencies": {
"@nx-tools/core": "6.0.1",
"clipanion": "^4.0.0-rc.3",
"chalk": "^4.1.2",
"semver": "^7.6.0"
"clipanion": "^4.0.0-rc.3",
"semver": "^7.6.2"
},
"peerDependencies": {
"tslib": "^2.5.0"
"@swc/helpers": "~0.5.11"
}
}
2 changes: 1 addition & 1 deletion packages/nx-set-shas/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"tags": ["type:cli", "scope:nx-set-shas"],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"executor": "@nx/js:swc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/nx-set-shas",
Expand Down
1 change: 1 addition & 0 deletions packages/nx-set-shas/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node

import { logger } from '@nx-tools/core';
import { Builtins, Cli } from 'clipanion';
import { version } from '../package.json';
Expand Down

0 comments on commit e0783e5

Please sign in to comment.