Skip to content

Commit

Permalink
feat: add files to reproduce ESM issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tstelzer committed May 16, 2021
1 parent ba8c04a commit 06025a9
Show file tree
Hide file tree
Showing 8 changed files with 3,523 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
16 changes: 16 additions & 0 deletions jest.config.js
@@ -0,0 +1,16 @@
export default {
// NOTE: This workaround seems to work, thanks to https://github.com/gadicc
// moduleNameMapper: {
// '^(\\./.*)\\.js$': '$1',
// },
globals: {
'ts-jest': {
useESM: true,
},
},
testEnvironment: 'node',
transform: {'^.+\\.tsx?$': 'ts-jest'},
testMatch: ['<rootDir>/src/**/*.spec.ts'],
extensionsToTreatAsEsm: ['.ts'],
moduleFileExtensions: ['ts', 'js'],
};
3,464 changes: 3,464 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions package.json
@@ -0,0 +1,21 @@
{
"name": "ts-jest-playground",
"version": "1.0.0",
"description": "",
"exports": "dist/a.js",
"type": "module",
"engines": {
"node": ">=12.20"
},
"scripts": {
"test": "jest --config=jest.config.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/jest": "^26.0.23",
"jest": "^27.0.0-next.9",
"ts-jest": "^27.0.0-next.12",
"typescript": "^4.2.4"
}
}
7 changes: 7 additions & 0 deletions src/a.spec.ts
@@ -0,0 +1,7 @@
import * as a from './a.js';

describe('a', () => {
test('foo', () => {
expect(a.foo()).toEqual(42);
})
})
3 changes: 3 additions & 0 deletions src/a.ts
@@ -0,0 +1,3 @@
import {bar} from './b.js';

export const foo = bar;
1 change: 1 addition & 0 deletions src/b.ts
@@ -0,0 +1 @@
export const bar = () => 42;
10 changes: 10 additions & 0 deletions tsconfig.json
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "esnext",
"module": "ES2020",
"moduleResolution": "node",
"esModuleInterop": true,
"noEmit": true
},
"include": [ "src" ]
}

0 comments on commit 06025a9

Please sign in to comment.