nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.58k stars 2.36k forks source link

After upgrading from NX17.3.0 to 17.3.1 loading file using .js extension fails with error Cannot find module #28711

Open wcwcaseman opened 6 days ago

wcwcaseman commented 6 days ago

Current Behavior

After upgrading from NX17.3.0 to 17.3.1 loading file using .js extension fails with error Cannot find module

example

import { Example as ExampleBase } from './example.js';

Module not found: Error: Cannot find module './example'

Expected Behavior

When loading files using extensions they should load without issue.

GitHub Repo

No response

Steps to Reproduce

  1. Create react nx repo with version 17.3.1
  2. Add import with .js extension

Nx Report

Node : 20.17.0 OS : darwin-x64 pnpm : 9.10.0

nx : 17.3.1 @nx/js : 17.3.1 @nx/jest : 17.3.1 @nx/linter : 17.3.1 @nx/eslint : 17.3.1 @nx/workspace : 17.3.1 @nx/cypress : 17.3.1 @nx/devkit : 17.3.1 @nx/eslint-plugin : 17.3.1 @nx/plugin : 17.3.1 @nx/react : 17.3.1 @nx/storybook : 17.3.1 @nrwl/tao : 17.3.1 @nx/web : 17.3.1 @nx/webpack : 17.3.1 typescript : 5.3.3

Community plugins: ts-check : 1.0.0

Local workspace plugins: @ecp/workspace-plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

ERROR in ../../../Example.info.tsx 5:0-60 Module not found: Error: Cannot find module './Example'

wcwcaseman commented 9 hours ago

This problem exists in the latest version of NX 20.0.8. I have added a merge request for the version where this functionality was broken.

In packages/nx/src/plugins/js/utils/register.ts

skipProject: true,

was added to service = register({

it needs to be removed to allow .js extension imports to work.