Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Unable to compile a project when using scripts v2.10.0 and up #246

Open
@codeaid

Description

@codeaid

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Yes

Which terms did you search for in User Guide?

Not really relevant, it's a TypeScript specific issue. Searched for module and resolve but there's nothing that would help.

Environment

  1. npm ls react-scripts-ts (if you haven’t ejected): 2.10.0, **

  2. node -v: 8.9.4

  3. npm -v: 5.6.0

  4. yarn --version (if you use Yarn): 1.3.2

  5. npm ls react-scripts-ts (if you haven’t ejected): Duplicated question (same as 1)?

  6. Operating system: Ubuntu

  7. Browser and version (if relevant): Not relevant

Steps to Reproduce

I am working on a project that was created using create-react-app and react-scripts-ts a while ago. Everything was compiling with no issues until I decided to update react-scripts-ts to the latest version.

The way the project is structured is as follows:

  • Every component resides in a separate directory and generally consists of the following files:

    • index.tsx - main component file
    • types.ts - component property and state interfaces declared inside a module (examples below)
    • styles.css - component specific stylesheets
  • Type definition files have the following format:

    declare module 'component-types' {
        export interface IMyComponentProps {
            // ...
        }
    
        export interface IMyComponentState {
            // ...
        }
    }
  • Main component file import dependencies and type declarations at the top of the file:

    import * as React from 'react';
    import {IMyComponentProps, IMyComponentState} from 'component-types';
    import './styles.css';
    
    export class MyComponent extends React.Component<IMyComponentProps, IMyComponentState> {
        // ...
    }

Previously there were no warnings while compiling, however, now I am getting the following message:

ts-loader: Using [email protected] and /var/www/my-project/tsconfig.json
No valid rules have been specified

That is a message that leads me to think that the loader is not picking up the tslint.json file for some reason.

As annoying as it is, I could live with that warning, however the bigger problem is that I am unable to compile my project any more as I am getting the following error:

Failed to compile.

Module not found: Error: Can't resolve 'component-types' in '/var/www/my-project/src/components/MyComponent'

There are plenty more of the same errors for lots of components in the developer tools console so it's not just one component.

I have tried different combinations of typescript and react-scripts-ts and none of them work. TypeScript 2.7.1 works with scripts version 2.8.0 so it's not related to TypeScript either.

Looking at the changes between 2.8.0 and 2.10.0, it looks like the biggest one is introduction of fork-ts-checker-webpack-plugin. Could that be something that brakes things?

Expected Behavior

Successful build just like with react-scripts-ts versions up to 2.8.0 (including).

Actual Behavior

See Steps to Reproduce.

Reproducible Demo

I am unable to supply any demo code as it's internal company code.

npm run build output

$ npm run build

> [email protected] build /var/www/my-project
> react-scripts-ts build

Creating an optimized production build...
Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
ts-loader: Using [email protected] and /var/www/my-project/tsconfig.json
No valid rules have been specified
Failed to compile.

Module not found: Error: Can't resolve 'cms-types' in '/var/www/my-project/src/components/MyComponent'


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts-ts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions