Skip to content

Commit 5fe4ca8

Browse files
Merge pull request #235 from hypermod-io/revert-esm
Revert esm
2 parents ef96f53 + e69f221 commit 5fe4ca8

File tree

15 files changed

+53
-89
lines changed

15 files changed

+53
-89
lines changed

.changeset/brown-camels-think.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@codeshift/cli': patch
3+
'@hypermod/cli': patch
4+
---
5+
6+
Reverts ESM support.

jest.config.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1-
/** @type {import('ts-jest').JestConfigWithTsJest} */
21
module.exports = {
32
transform: {
4-
'\\.[jt]sx?$': [
3+
'^.+\\.ts$': [
54
'ts-jest',
65
{
7-
diagnostics: { ignoreCodes: [1343] },
8-
astTransformers: {
9-
before: [
10-
{
11-
path: 'node_modules/ts-jest-mock-import-meta', // or, alternatively, 'ts-jest-mock-import-meta' directly, without node_modules.
12-
options: {
13-
metaObjectReplacement: { url: 'https://www.url.com' },
14-
},
15-
},
16-
],
17-
},
6+
tsconfig: 'tsconfig.json',
187
},
198
],
209
},
@@ -26,7 +15,6 @@ module.exports = {
2615
'jest-watch-typeahead/testname',
2716
],
2817
moduleNameMapper: {
29-
'(.+)\\.js$': '$1',
3018
'@hypermod/(.*)$': '<rootDir>/packages/$1/src',
3119
'@codeshift/(.*)$': '<rootDir>/packages/$1/src',
3220
},

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"semver": "^7.3.5",
7070
"tar": "^6.1.0",
7171
"ts-jest": "^29.2.5",
72-
"ts-jest-mock-import-meta": "^1.2.0",
7372
"ts-loader": "^6.2.1",
7473
"ts-node": "^10.9.1",
7574
"tslib": "^2.2.0",
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
#!/usr/bin/env node
2-
export * from '../dist/index.js';
2+
const path = require('path');
3+
4+
require(path.join('..', 'dist', 'index.js'));

packages/cli-alias/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@codeshift/cli",
33
"version": "0.23.0",
4-
"type": "module",
54
"source": "src/index.ts",
65
"main": "dist/index.js",
76
"types": "dist/index.d.ts",

packages/cli/bin/hypermod-cli.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
#!/usr/bin/env node
2-
export * from '../dist/index.js';
2+
const path = require('path');
3+
4+
require(path.join('..', 'dist', 'index.js'));

packages/cli/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@hypermod/cli",
33
"version": "0.23.0",
4-
"type": "module",
54
"source": "src/index.ts",
65
"main": "dist/index.js",
76
"types": "dist/index.d.ts",

packages/cli/src/index.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@ import { readFileSync } from 'fs';
33
import chalk from 'chalk';
44
import { Command, Option, CommanderError } from 'commander';
55

6-
import main from './main.js';
7-
import list from './list.js';
8-
import init from './init.js';
9-
import validate from './validate.js';
10-
import { InvalidUserInputError, InvalidConfigError } from './errors.js';
6+
import main from './main';
7+
import list from './list';
8+
import init from './init';
9+
import validate from './validate';
10+
import { InvalidUserInputError, InvalidConfigError } from './errors';
1111

1212
const packageJson = readFileSync(
13-
path.join(
14-
path.dirname(new URL(import.meta.url).pathname),
15-
'..',
16-
'package.json',
17-
),
13+
path.join(__dirname, '..', 'package.json'),
1814
'utf-8',
1915
);
2016

packages/cli/src/list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import chalk from 'chalk';
22
import { PluginManager } from 'live-plugin-manager';
33

4-
import { fetchPackages } from './utils/fetch-package.js';
5-
import { getHypermodPackageName } from './utils/package-names.js';
4+
import { fetchPackages } from './utils/fetch-package';
5+
import { getHypermodPackageName } from './utils/package-names';
66

77
export default async function list(packages: string[]) {
88
const packageManager = new PluginManager();

packages/cli/src/main.ts

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ import { installPackage } from '@antfu/install-pkg';
1010
import * as core from '@hypermod/core';
1111
import { fetchConfigAtPath } from '@hypermod/fetcher';
1212

13-
import { InvalidUserInputError } from './errors.js';
14-
import { fetchPackages } from './utils/fetch-package.js';
15-
import { mergeConfigs } from './utils/merge-configs.js';
16-
import {
17-
fetchConfigsForWorkspaces,
18-
getPackageJson,
19-
} from './utils/file-system.js';
20-
import { getConfigPrompt, getMultiConfigPrompt } from './prompt.js';
13+
import { InvalidUserInputError } from './errors';
14+
import { fetchPackages } from './utils/fetch-package';
15+
import { mergeConfigs } from './utils/merge-configs';
16+
import { fetchConfigsForWorkspaces, getPackageJson } from './utils/file-system';
17+
import { getConfigPrompt, getMultiConfigPrompt } from './prompt';
2118

2219
const ExperimentalModuleLoader = () => {
2320
const getInfo = (packageName: string) => {
@@ -37,7 +34,6 @@ const ExperimentalModuleLoader = () => {
3734
};
3835

3936
const install = async (packageName: string) => {
40-
const __dirname = path.dirname(new URL(import.meta.url).pathname);
4137
await installPackage(packageName, {
4238
cwd: __dirname,
4339
packageManager: 'npm',
@@ -80,11 +76,7 @@ export default async function main(
8076
}
8177

8278
const pluginManagerConfig: Partial<PluginManagerOptions> = {
83-
pluginsPath: path.join(
84-
path.dirname(new URL(import.meta.url).pathname),
85-
'..',
86-
'node_modules',
87-
),
79+
pluginsPath: path.join(__dirname, '..', 'node_modules'),
8880
};
8981

9082
// If a registry is provided in the CLI flags, use it for the pluginManagers configuration.
@@ -164,33 +156,21 @@ export default async function main(
164156
*/
165157
const configFilePath = await findUp([
166158
'hypermod.config.js',
167-
'hypermod.config.cjs',
168-
'hypermod.config.mjs',
169159
'hypermod.config.ts',
170160
'hypermod.config.tsx',
171161
'src/hypermod.config.js',
172-
'src/hypermod.config.cjs',
173-
'src/hypermod.config.mjs',
174162
'src/hypermod.config.ts',
175163
'src/hypermod.config.tsx',
176164
'codemods/hypermod.config.js',
177-
'codemods/hypermod.config.cjs',
178-
'codemods/hypermod.config.mjs',
179165
'codemods/hypermod.config.ts',
180166
'codemods/hypermod.config.tsx',
181167
'codeshift.config.js',
182-
'codeshift.config.cjs',
183-
'codeshift.config.mjs',
184168
'codeshift.config.ts',
185169
'codeshift.config.tsx',
186170
'src/codeshift.config.js',
187-
'src/codeshift.config.cjs',
188-
'src/codeshift.config.mjs',
189171
'src/codeshift.config.ts',
190172
'src/codeshift.config.tsx',
191173
'codemods/codeshift.config.js',
192-
'codemods/codeshift.config.cjs',
193-
'codemods/codeshift.config.mjs',
194174
'codemods/codeshift.config.ts',
195175
'codemods/codeshift.config.tsx',
196176
]);

0 commit comments

Comments
 (0)