-
Notifications
You must be signed in to change notification settings - Fork 492
Unable to compile a project when using scripts v2.10.0 and up #246
Comments
These are two different issues.
It's hard to tell or figure out more with a reproduction, though. |
As the issue title says - it's happening with versions of I went back to debugging the problem after I posted the issue. I created an new Long story short - after lots of swearing and experimenting, I discovered that the one thing those components had in common was that they were exporting const enums from ambient modules like this: declare module 'cms-types' {
export interface ISomeInterface {
foo: string;
}
export const enum SomeType {
Foo = 'foo',
Bar = 'bar',
}
} The way I managed to fix it is by moving the enum declaration to a separate file: // some/path/to/enums.ts
export const enum SomeType {
Foo = 'foo',
Bar = 'bar',
} ...and importing it as from a normal module: import {ISomeInterface} from 'cms-types';
import {SomeType} from 'some/path/to/enums';
// ... The ambient module declaration only contained the interfaces after that: declare module 'cms-types' {
export interface ISomeInterface {
foo: string;
}
} Additionally, it does not show the "No valid rules have been specified" warning anymore after moving enums to separate files. I am still baffled as to why it works with Any ideas on what could cause this behaviour? I certainly can't think of any without knowing the internals of |
Potentially, yes - but not necessarily in an unintended way. Other steps - it's somewhat easy to figure out if this issue only occurs due to the added plugin, or if one of the other updates might have caused this. create-react-app-typescript/packages/react-scripts/config/webpack.config.dev.js Lines 159 to 172 in 7149b37
2: Remove the fork-ts-checker-webpack-plugin here:create-react-app-typescript/packages/react-scripts/config/webpack.config.dev.js Lines 265 to 272 in 7149b37
If the Besides, I don't think this kind of usage of ambient modules is intended - their intention is to use them for creating definitions for javascript modules (libraries), and not for local modules that don't even exist or contain any executable source code after transpilation. |
Thanks for detailed explanation! Much appreciated! Firstly, you can find my Having read more about modules lately I do realise that my current setup is probably not 100% correct but I can't really think of where else could I put my component interface definitions. I don't want to have them in the same file as the component definition and I would prefer not to move them into some globally accessible directory (e.g. *.d.ts files in ./typings) either. I'll try applying your suggestions on Monday when I'm back at work but even if they don't work, I have managed to fix my build by just moving all my enum definitions to separate files, which actually makes more sense now. I'll keep you posted! It would be interesting to get to the bottom of this problem. |
Here is the root cause: TypeStrong/ts-loader#331 |
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
andresolve
but there's nothing that would help.Environment
npm ls react-scripts-ts
(if you haven’t ejected): 2.10.0, **node -v
: 8.9.4npm -v
: 5.6.0yarn --version
(if you use Yarn): 1.3.2npm ls react-scripts-ts
(if you haven’t ejected): Duplicated question (same as 1)?Operating system: Ubuntu
Browser and version (if relevant): Not relevant
Steps to Reproduce
I am working on a project that was created using
create-react-app
andreact-scripts-ts
a while ago. Everything was compiling with no issues until I decided to updatereact-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:
Type definition files have the following format:
Main component file import dependencies and type declarations at the top of the file:
Previously there were no warnings while compiling, however, now I am getting the following message:
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:
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
andreact-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
The text was updated successfully, but these errors were encountered: