Skip to content

Commit 678a34e

Browse files
committed
feat(npm-tools): normalize paths
See the thread: #387 (comment) for a discussion regarding this feature.
1 parent 7ff42cf commit 678a34e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

projects/npm-tools/packages/npm-scripts/src/utils/createFederationConfig.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,19 @@ module.exports = async function () {
263263
};
264264
};
265265

266-
function transformExposes(exposes, inputDirectory) {
266+
function transformExposes(exposes, inputDir) {
267267
return exposes.reduce((exposes, filePath) => {
268-
const exposeName = path.posix
269-
.relative('.', filePath)
270-
.replace(/\.js$/i, '');
268+
if (!filePath.startsWith('<inputDir>/')) {
269+
throw new Error(
270+
"Only paths relative to '<inputDir>/' are accepted as 'exposes'"
271+
);
272+
}
271273

272-
exposes[exposeName] = `./${inputDirectory}/${filePath}`;
274+
filePath = filePath.replace(/^<inputDir>\//, '');
275+
276+
const exposeName = filePath.replace(/\.js$/i, '');
277+
278+
exposes[exposeName] = `./${inputDir}/${filePath}`;
273279

274280
return exposes;
275281
}, {});

0 commit comments

Comments
 (0)