fix(js): update generated .swcrc file to align with @swc/core@1.3.85 (#19214)
Co-authored-by: Jason Jean <jasonjean1993@gmail.com>
This commit is contained in:
parent
75890f58dd
commit
903c4fe7c8
@ -50,8 +50,7 @@ describe('js:node executor', () => {
|
|||||||
expect(output).toContain('This is an error');
|
expect(output).toContain('This is an error');
|
||||||
}, 240_000);
|
}, 240_000);
|
||||||
|
|
||||||
// TODO: Re-enable this when it is passing
|
it('should execute library compiled with rollup', async () => {
|
||||||
xit('should execute library compiled with rollup', async () => {
|
|
||||||
const rollupLib = uniq('rolluplib');
|
const rollupLib = uniq('rolluplib');
|
||||||
|
|
||||||
runCLI(
|
runCLI(
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
import { satisfies } from 'semver';
|
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import {
|
import {
|
||||||
checkFilesDoNotExist,
|
|
||||||
checkFilesExist,
|
checkFilesExist,
|
||||||
cleanupProject,
|
cleanupProject,
|
||||||
detectPackageManager,
|
detectPackageManager,
|
||||||
@ -9,7 +7,6 @@ import {
|
|||||||
packageManagerLockFile,
|
packageManagerLockFile,
|
||||||
readJson,
|
readJson,
|
||||||
runCLI,
|
runCLI,
|
||||||
runCLIAsync,
|
|
||||||
tmpProjPath,
|
tmpProjPath,
|
||||||
uniq,
|
uniq,
|
||||||
updateFile,
|
updateFile,
|
||||||
@ -65,14 +62,9 @@ describe('js:swc executor', () => {
|
|||||||
packageManagerLockFile[detectPackageManager(tmpProjPath())]
|
packageManagerLockFile[detectPackageManager(tmpProjPath())]
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
expect(
|
expect(readJson(`dist/libs/${lib}/package.json`)).toHaveProperty(
|
||||||
satisfies(
|
'peerDependencies.@swc/helpers'
|
||||||
readJson(`dist/libs/${lib}/package.json`).peerDependencies[
|
);
|
||||||
'@swc/helpers'
|
|
||||||
],
|
|
||||||
readJson(`package.json`).dependencies['@swc/helpers']
|
|
||||||
)
|
|
||||||
).toBeTruthy();
|
|
||||||
|
|
||||||
// Legacy behavior (updateBuildableProjectDepsInPackageJson): don't add @swc/helpers if externalHelpers is false
|
// Legacy behavior (updateBuildableProjectDepsInPackageJson): don't add @swc/helpers if externalHelpers is false
|
||||||
// TODO(v17): Remove this test
|
// TODO(v17): Remove this test
|
||||||
|
|||||||
@ -22,8 +22,7 @@ describe('packaging libs', () => {
|
|||||||
|
|
||||||
afterEach(() => cleanupProject());
|
afterEach(() => cleanupProject());
|
||||||
|
|
||||||
// TODO Re-enable this when it is passing
|
it('should bundle libs using esbuild, vite, rollup and be used in CJS/ESM projects', () => {
|
||||||
xit('should bundle libs using esbuild, vite, rollup and be used in CJS/ESM projects', () => {
|
|
||||||
const esbuildLib = uniq('esbuildlib');
|
const esbuildLib = uniq('esbuildlib');
|
||||||
const viteLib = uniq('vitelib');
|
const viteLib = uniq('vitelib');
|
||||||
const rollupLib = uniq('rolluplib');
|
const rollupLib = uniq('rolluplib');
|
||||||
@ -130,8 +129,7 @@ describe('packaging libs', () => {
|
|||||||
expect(output).toContain('rollup default');
|
expect(output).toContain('rollup default');
|
||||||
}, 500_000);
|
}, 500_000);
|
||||||
|
|
||||||
// TODO Re-enable this when it is passing
|
it('should build with tsc, swc and be used in CJS/ESM projects', async () => {
|
||||||
xit('should build with tsc, swc and be used in CJS/ESM projects', async () => {
|
|
||||||
const tscLib = uniq('tsclib');
|
const tscLib = uniq('tsclib');
|
||||||
const swcLib = uniq('swclib');
|
const swcLib = uniq('swclib');
|
||||||
const tscEsmLib = uniq('tscesmlib');
|
const tscEsmLib = uniq('tscesmlib');
|
||||||
|
|||||||
@ -114,8 +114,7 @@ describe('Rollup Plugin', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Re-enable this when it is passing
|
it('should be able to build libs generated with @nx/js:lib --bundler rollup', () => {
|
||||||
xit('should be able to build libs generated with @nx/js:lib --bundler rollup', () => {
|
|
||||||
const jsLib = uniq('jslib');
|
const jsLib = uniq('jslib');
|
||||||
runCLI(`generate @nx/js:lib ${jsLib} --bundler rollup`);
|
runCLI(`generate @nx/js:lib ${jsLib} --bundler rollup`);
|
||||||
expect(() => runCLI(`build ${jsLib}`)).not.toThrow();
|
expect(() => runCLI(`build ${jsLib}`)).not.toThrow();
|
||||||
|
|||||||
@ -100,9 +100,9 @@
|
|||||||
"@supabase/supabase-js": "^2.26.0",
|
"@supabase/supabase-js": "^2.26.0",
|
||||||
"@svgr/rollup": "^8.0.1",
|
"@svgr/rollup": "^8.0.1",
|
||||||
"@svgr/webpack": "^8.0.1",
|
"@svgr/webpack": "^8.0.1",
|
||||||
"@swc-node/register": "^1.4.2",
|
"@swc-node/register": "^1.6.7",
|
||||||
"@swc/cli": "0.1.62",
|
"@swc/cli": "0.1.62",
|
||||||
"@swc/core": "^1.3.51",
|
"@swc/core": "^1.3.85",
|
||||||
"@swc/jest": "^0.2.20",
|
"@swc/jest": "^0.2.20",
|
||||||
"@testing-library/react": "13.4.0",
|
"@testing-library/react": "13.4.0",
|
||||||
"@types/cytoscape": "^3.18.2",
|
"@types/cytoscape": "^3.18.2",
|
||||||
|
|||||||
@ -47,6 +47,12 @@
|
|||||||
"version": "16.6.0-beta.0",
|
"version": "16.6.0-beta.0",
|
||||||
"description": "Explicitly set 'updateBuildableProjectDepsInPackageJson' to 'true' in targets that rely on that value as the default.",
|
"description": "Explicitly set 'updateBuildableProjectDepsInPackageJson' to 'true' in targets that rely on that value as the default.",
|
||||||
"factory": "./src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps"
|
"factory": "./src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps"
|
||||||
|
},
|
||||||
|
"16-8-2-update-swcrc": {
|
||||||
|
"cli": "nx",
|
||||||
|
"version": "16.8.2-beta.0",
|
||||||
|
"description": "Remove invalid options (strict, noInterop) for ES6 type modules.",
|
||||||
|
"factory": "./src/migrations/update-16-8-2/update-swcrc"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packageJsonUpdates": {
|
"packageJsonUpdates": {
|
||||||
@ -98,6 +104,19 @@
|
|||||||
"version": "~5.1.3"
|
"version": "~5.1.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"16.8.2": {
|
||||||
|
"version": "16.8.2-beta.0",
|
||||||
|
"packages": {
|
||||||
|
"@swc/core": {
|
||||||
|
"version": "~1.3.85",
|
||||||
|
"alwaysAddToPackageJson": false
|
||||||
|
},
|
||||||
|
"@swc/helpers": {
|
||||||
|
"version": "~0.5.2",
|
||||||
|
"alwaysAddToPackageJson": false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,82 @@
|
|||||||
|
import { addProjectConfiguration, readJson, Tree, writeJson } from '@nx/devkit';
|
||||||
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
||||||
|
import update from './update-swcrc';
|
||||||
|
|
||||||
|
describe('Migration: update .swcrc', () => {
|
||||||
|
let tree: Tree;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
tree = createTreeWithEmptyWorkspace();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove invalid options for ES6 modules', async () => {
|
||||||
|
addProjectConfiguration(tree, 'pkg', {
|
||||||
|
root: 'pkg',
|
||||||
|
});
|
||||||
|
writeJson(tree, 'pkg/.swcrc', {
|
||||||
|
module: {
|
||||||
|
type: 'es6',
|
||||||
|
strict: true,
|
||||||
|
noInterop: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await update(tree);
|
||||||
|
|
||||||
|
expect(readJson(tree, 'pkg/.swcrc')).toEqual({
|
||||||
|
module: {
|
||||||
|
type: 'es6',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should keep options for CommonJS modules', async () => {
|
||||||
|
addProjectConfiguration(tree, 'pkg', {
|
||||||
|
root: 'pkg',
|
||||||
|
});
|
||||||
|
writeJson(tree, 'pkg/.swcrc', {
|
||||||
|
module: {
|
||||||
|
type: 'commonjs',
|
||||||
|
strict: true,
|
||||||
|
noInterop: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await update(tree);
|
||||||
|
|
||||||
|
expect(readJson(tree, 'pkg/.swcrc')).toEqual({
|
||||||
|
module: {
|
||||||
|
type: 'commonjs',
|
||||||
|
strict: true,
|
||||||
|
noInterop: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should ignore projects without module options in .swcrc', async () => {
|
||||||
|
addProjectConfiguration(tree, 'pkg', {
|
||||||
|
root: 'pkg',
|
||||||
|
});
|
||||||
|
writeJson(tree, 'pkg/.swcrc', {
|
||||||
|
jsc: {
|
||||||
|
target: 'es2017',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(update(tree)).resolves.not.toThrow();
|
||||||
|
|
||||||
|
expect(readJson(tree, 'pkg/.swcrc')).toEqual({
|
||||||
|
jsc: {
|
||||||
|
target: 'es2017',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should ignore projects without .swcrc', async () => {
|
||||||
|
addProjectConfiguration(tree, 'pkg', {
|
||||||
|
root: 'pkg',
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(update(tree)).resolves.not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
30
packages/js/src/migrations/update-16-8-2/update-swcrc.ts
Normal file
30
packages/js/src/migrations/update-16-8-2/update-swcrc.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import {
|
||||||
|
formatFiles,
|
||||||
|
getProjects,
|
||||||
|
readJson,
|
||||||
|
Tree,
|
||||||
|
writeJson,
|
||||||
|
} from '@nx/devkit';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
export default async function update(tree: Tree) {
|
||||||
|
const projects = getProjects(tree);
|
||||||
|
|
||||||
|
for (const config of projects.values()) {
|
||||||
|
const swcrcPath = join(config.root, '.swcrc');
|
||||||
|
if (!tree.exists(swcrcPath)) continue;
|
||||||
|
const json = readJson(tree, swcrcPath);
|
||||||
|
// No longer need strict or noInterop for es6 modules
|
||||||
|
// See: https://github.com/swc-project/swc/commit/7e8d72d
|
||||||
|
if (
|
||||||
|
json.module?.type === 'es6' &&
|
||||||
|
(json.module?.strict || json.module?.noInterop)
|
||||||
|
) {
|
||||||
|
delete json.module.noInterop;
|
||||||
|
delete json.module.strict;
|
||||||
|
writeJson(tree, swcrcPath, json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await formatFiles(tree);
|
||||||
|
}
|
||||||
@ -27,9 +27,7 @@ const swcOptionsString = (type: 'commonjs' | 'es6' = 'commonjs') => `{
|
|||||||
"loose": true
|
"loose": true
|
||||||
},
|
},
|
||||||
"module": {
|
"module": {
|
||||||
"type": "${type}",
|
"type": "${type}"
|
||||||
"strict": true,
|
|
||||||
"noInterop": true
|
|
||||||
},
|
},
|
||||||
"sourceMaps": true,
|
"sourceMaps": true,
|
||||||
"exclude": ${JSON.stringify(defaultExclude)}
|
"exclude": ${JSON.stringify(defaultExclude)}
|
||||||
|
|||||||
@ -3,8 +3,8 @@ export const nxVersion = require('../../package.json').version;
|
|||||||
export const esbuildVersion = '^0.17.17';
|
export const esbuildVersion = '^0.17.17';
|
||||||
export const prettierVersion = '^2.6.2';
|
export const prettierVersion = '^2.6.2';
|
||||||
export const swcCliVersion = '~0.1.62';
|
export const swcCliVersion = '~0.1.62';
|
||||||
export const swcCoreVersion = '~1.3.51';
|
export const swcCoreVersion = '~1.3.85';
|
||||||
export const swcHelpersVersion = '~0.5.0';
|
export const swcHelpersVersion = '~0.5.2';
|
||||||
export const swcNodeVersion = '~1.4.2';
|
export const swcNodeVersion = '~1.4.2';
|
||||||
export const tsLibVersion = '^2.3.0';
|
export const tsLibVersion = '^2.3.0';
|
||||||
export const typesNodeVersion = '18.7.1';
|
export const typesNodeVersion = '18.7.1';
|
||||||
|
|||||||
@ -69,8 +69,8 @@
|
|||||||
"node-machine-id": "1.1.12"
|
"node-machine-id": "1.1.12"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@swc-node/register": "^1.4.2",
|
"@swc-node/register": "^1.6.7",
|
||||||
"@swc/core": "^1.2.173"
|
"@swc/core": "^1.3.85"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"@swc-node/register": {
|
"@swc-node/register": {
|
||||||
|
|||||||
558
pnpm-lock.yaml
generated
558
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@
|
|||||||
"@nx/docs/*": ["docs/*"],
|
"@nx/docs/*": ["docs/*"],
|
||||||
"@nx/e2e/utils": ["e2e/utils"],
|
"@nx/e2e/utils": ["e2e/utils"],
|
||||||
"@nx/esbuild": ["packages/esbuild"],
|
"@nx/esbuild": ["packages/esbuild"],
|
||||||
"@nx/eslint-plugin": ["packages/eslint-plugin/src"],
|
"@nx/eslint-plugin": ["packages/eslint-plugin/src/index.ts"],
|
||||||
"@nx/expo": ["packages/expo"],
|
"@nx/expo": ["packages/expo"],
|
||||||
"@nx/expo/*": ["packages/expo/*"],
|
"@nx/expo/*": ["packages/expo/*"],
|
||||||
"@nx/express": ["packages/express"],
|
"@nx/express": ["packages/express"],
|
||||||
@ -38,7 +38,7 @@
|
|||||||
"@nx/graph/ui-tooltips": ["graph/ui-tooltips/src/index.ts"],
|
"@nx/graph/ui-tooltips": ["graph/ui-tooltips/src/index.ts"],
|
||||||
"@nx/jest": ["packages/jest"],
|
"@nx/jest": ["packages/jest"],
|
||||||
"@nx/jest/*": ["packages/jest/*"],
|
"@nx/jest/*": ["packages/jest/*"],
|
||||||
"@nx/js": ["packages/js/src"],
|
"@nx/js": ["packages/js/src/index.ts"],
|
||||||
"@nx/js/*": ["packages/js/*"],
|
"@nx/js/*": ["packages/js/*"],
|
||||||
"@nx/linter": ["packages/linter"],
|
"@nx/linter": ["packages/linter"],
|
||||||
"@nx/linter/*": ["packages/linter/*"],
|
"@nx/linter/*": ["packages/linter/*"],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user