diff --git a/.changeset/yellow-ducks-burn.md b/.changeset/yellow-ducks-burn.md new file mode 100644 index 0000000000..c76a548d54 --- /dev/null +++ b/.changeset/yellow-ducks-burn.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Allow js files to be processed by the nodeTransform loader diff --git a/packages/cli/config/nodeTransformHooks.mjs b/packages/cli/config/nodeTransformHooks.mjs index 5d37ac05c0..0e7b14f929 100644 --- a/packages/cli/config/nodeTransformHooks.mjs +++ b/packages/cli/config/nodeTransformHooks.mjs @@ -127,10 +127,10 @@ async function withDetectedModuleType(resolved) { }; } - // TODO(Rugvip): Afaik this should never happen and we can remove this check, but want it here for a little while to verify. - if (ext === '.js') { - throw new Error('Unexpected .js file without explicit format'); - } + // Under normal circumstances .js files should reliably have a format and so + // we should only reach this point for .ts files. However, if additional + // custom loaders are being used the format may not be detected for .js files + // either. As such we don't restrict the file format at this point. // TODO(Rugvip): Does this need caching? kept it simple for now but worth exploring const packageJsonPath = await findPackageJSON(fileURLToPath(resolved.url));