Skip to content

Commit

Permalink
build: improve nx-resolve-packages rollup plugin by marking packages …
Browse files Browse the repository at this point in the history
…as external
  • Loading branch information
marcus-sa committed Sep 11, 2023
1 parent 8c1e721 commit 1754722
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const path = require('node:path');
const { workspaceRoot } = require('@nx/devkit');
const { readFile } = require('fs/promises');

const tsconfig = require(path.join(workspaceRoot, 'tsconfig.base.json'));

Expand All @@ -16,15 +15,16 @@ const nxResolvePackages = (packages) => {

const projectName = importee.split('/')[1];

const distProjectPath = path.join(workspaceRoot, 'dist/packages', projectName);
const projectPath = path.join(workspaceRoot, 'dist/packages', projectName);

const packageJson = JSON.parse(await readFile(path.join(distProjectPath, 'package.json'), 'utf8'));
const relativeIndexFilePath = packageJson.module || packageJson.main;
const result = {
id: projectPath,
external: true
}

const absoluteMainFilePath = path.join(distProjectPath, relativeIndexFilePath);
cache.set(importee, absoluteMainFilePath);
cache.set(importee, result);

return absoluteMainFilePath;
return result;
},
}
}
Expand Down

0 comments on commit 1754722

Please sign in to comment.