Skip to content

Commit f58e49f

Browse files
test: add esm loader test (#5383)
* test: add esm loader test * test: add esm loader test --------- Co-authored-by: Josh Goldberg ✨ <[email protected]>
1 parent 295c168 commit f58e49f

File tree

13 files changed

+196
-0
lines changed

13 files changed

+196
-0
lines changed

eslint.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ module.exports = [
6868
sourceType: 'module'
6969
}
7070
},
71+
{
72+
files: [
73+
'test/compiler-esm/*.js'
74+
],
75+
languageOptions: {
76+
sourceType: 'module',
77+
// For top-level await support.
78+
ecmaVersion: 2022,
79+
}
80+
},
7181
{
7282
files: ['test/**/*.{js,mjs}'],
7383
languageOptions: {

test/compiler-esm/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"//": "Setting default type for .ts files as ESM as well",
3+
"type": "module"
4+
}

test/compiler-esm/test-tla.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const obj = { foo: 'bar' };
2+
3+
describe('esm written in esm with top-level-await', () => {
4+
it('should work', () => {
5+
expect(obj, 'to equal', { foo: 'bar' });
6+
});
7+
});
8+
9+
await undefined;
10+
11+
export const foo = 'bar';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const obj = { foo: 'bar' };
2+
3+
describe('esm written in esm with top-level-await', () => {
4+
it('should work', () => {
5+
expect(obj, 'to equal', { foo: 'bar' });
6+
});
7+
});
8+
9+
await undefined;
10+
11+
export const foo = 'bar';

test/compiler-esm/test-tla.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const obj: unknown = { foo: 'bar' };
2+
enum Foo {
3+
Bar = 'bar',
4+
}
5+
6+
describe('esm written in esm with top-level-await', () => {
7+
it('should work', () => {
8+
expect(obj, 'to equal', { foo: Foo.Bar });
9+
});
10+
});
11+
12+
await undefined;
13+
14+
export const foo = 'bar';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const obj = { foo: 'bar' };
2+
const Foo = {
3+
Bar: 'bar',
4+
};
5+
6+
describe('esm written in esm with top-level-await', () => {
7+
it('should work', () => {
8+
expect(obj, 'to equal', { foo: Foo.Bar });
9+
});
10+
});
11+
12+
await undefined;
13+
14+
export const foo = 'bar';

test/compiler-esm/test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const obj = { foo: 'bar' };
2+
3+
describe('esm written in esm', () => {
4+
it('should work', () => {
5+
expect(obj, 'to equal', { foo: 'bar' });
6+
});
7+
});
8+
9+
export const foo = 'bar';

test/compiler-esm/test.js.compiled

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const obj = { foo: 'bar' };
2+
3+
describe('esm written in esm', () => {
4+
it('should work', () => {
5+
expect(obj, 'to equal', { foo: 'bar' });
6+
});
7+
});
8+
9+
export const foo = 'bar';

test/compiler-esm/test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const obj: unknown = { foo: 'bar' };
2+
enum Foo {
3+
Bar = 'bar',
4+
};
5+
6+
describe('esm written in esm', () => {
7+
it('should work', () => {
8+
expect(obj, 'to equal', { foo: Foo.Bar });
9+
});
10+
});
11+
12+
export const foo = 'bar';

test/compiler-esm/test.ts.compiled

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const obj = { foo: 'bar' };
2+
const Foo = {
3+
Bar: 'bar',
4+
};
5+
6+
describe('esm written in esm', () => {
7+
it('should work', () => {
8+
expect(obj, 'to equal', { foo: Foo.Bar });
9+
});
10+
});
11+
12+
export const foo = 'bar';

0 commit comments

Comments
 (0)