Skip to content

Commit

Permalink
fix(core): add support for .mts and .mjs files when creating pro… (#1…
Browse files Browse the repository at this point in the history
…6679)

(cherry picked from commit 13aaa20)
  • Loading branch information
vneogi199 authored and FrozenPandaz committed May 1, 2023
1 parent 15bfd52 commit c9f37fe
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,48 @@ describe('explicit project dependencies', () => {
]);
});

it('should build explicit dependencies for static exports in .mts files', async () => {
const sourceProjectName = 'proj';
const { ctx, builder } = await createVirtualWorkspace({
sourceProjectName,
sourceProjectFiles: [
{
path: 'libs/proj/index.mts',
content: `
export {a} from '@proj/my-second-proj';
export * as project3 from '@proj/project-3';
export * from '@proj/proj4ab';
`,
},
],
});

const res = buildExplicitTypeScriptDependencies(
builder.graph,
ctx.filesToProcess
);
expect(res).toEqual([
{
sourceProjectName,
sourceProjectFile: 'libs/proj/index.mts',
targetProjectName: 'proj2',
type: 'static',
},
{
sourceProjectName,
sourceProjectFile: 'libs/proj/index.mts',
targetProjectName: 'proj3a',
type: 'static',
},
{
sourceProjectName,
sourceProjectFile: 'libs/proj/index.mts',
targetProjectName: 'proj4ab',
type: 'static',
},
]);
});

it(`should build explicit dependencies for TypeScript's import/export require syntax, and side-effectful import`, async () => {
const sourceProjectName = 'proj';
const { ctx, builder } = await createVirtualWorkspace({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ export class TypeScriptImportLocator {
const extension = path.extname(filePath);
if (
extension !== '.ts' &&
extension !== '.mts' &&
extension !== '.tsx' &&
extension !== '.js' &&
extension !== '.mjs' &&
extension !== '.jsx'
) {
return;
Expand Down

0 comments on commit c9f37fe

Please sign in to comment.