Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/little-snakes-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@module-federation/third-party-dts-extractor': patch
'@module-federation/dts-plugin': patch
---

fix: do not collect node internal utils
13 changes: 11 additions & 2 deletions packages/dts-plugin/tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { rmSync } from 'fs';
import path from 'path';
import { rmSync } from 'fs';

const TEMP_TS_CONFIG_DIR = path.resolve(__dirname, 'node_modules/.federation');
const TEMP_TS_CONFIG_DIR = path.resolve(
__dirname,
'../node_modules/.federation',
);
try {
rmSync(TEMP_TS_CONFIG_DIR, { recursive: true });
} catch (err) {
// noop
}
const TEMP_DIST = path.resolve(__dirname, '../dist-test');
try {
rmSync(TEMP_DIST, { recursive: true });
} catch (err) {
// noop
}
3 changes: 1 addition & 2 deletions packages/dts-plugin/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import path from 'path';
import './tests/setup';

import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

Expand All @@ -20,6 +20,5 @@ export default defineConfig({
],
reporters: ['default'],
testTimeout: 60000,
setupFiles: [path.resolve(__dirname, './tests/setup.ts')],
},
});
7 changes: 7 additions & 0 deletions packages/third-party-dts-extractor/src/ThirdPartyExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { getTypedName } from './utils';

const ignoredPkgs = ['typescript'];

// require.resolve('path')==='path'
const isNodeUtils = (pkgJsonPath: string, importPath: string) => {
return pkgJsonPath === importPath;
};
class ThirdPartyExtractor {
pkgs: Record<string, string>;
pattern: RegExp;
Expand Down Expand Up @@ -41,6 +45,9 @@ class ThirdPartyExtractor {
const pkgJsonPath = findPkg.sync(
require.resolve(importPath, { paths: [this.context] }),
) as string;
if (isNodeUtils(pkgJsonPath, importPath)) {
return;
}
const dir = path.dirname(pkgJsonPath);
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8')) as Record<
string,
Expand Down