Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework Build - Typescript Error #3053

Closed
cjreimer opened this issue Jul 16, 2021 · 10 comments · Fixed by #3082
Closed

Framework Build - Typescript Error #3053

cjreimer opened this issue Jul 16, 2021 · 10 comments · Fixed by #3082

Comments

@cjreimer
Copy link
Contributor

Hello,

I'm having trouble building the framework as soon as I touch a typescript file. I've tried touching files in both the internal and web packages and get the same issue. The error I get is:

[9:18:22 a.m.] Project '../../packages/web/tsconfig.json' is out of date because oldest output '../../packages/web/dist/config.d.ts' is older than newest input '../../packages/web/src/components/GraphQLHooksProvider.tsx'

[9:18:22 a.m.] Building project 'D:/dev/redwoodjs/redwood/packages/web/tsconfig.json'...

D:\dev\redwoodjs\redwood\tasks\framework-tools\node_modules\typescript\lib\typescript.js:2479
            throw e;
            ^

Error: Debug Failure. False expression: File extension for signature expected to be dts
Verbose Debug Information: Found: .map for D:/dev/redwoodjs/redwood/packages/web/dist/components/GraphQLHooksProvider.d.ts.map:: All output files: ["D:/dev/redwoodjs/redwood/packages/web/dist/components/GraphQLHooksProvider.d.ts.map","D:/dev/redwoodjs/redwood/packages/web/dist/components/GraphQLHooksProvider.d.ts"]
    at updateShapeSignature (D:\dev\redwoodjs\redwood\tasks\framework-tools\node_modules\typescript\lib\typescript.js:112521:30)      
    at Object.getFilesAffectedBy (D:\dev\redwoodjs\redwood\tasks\framework-tools\node_modules\typescript\lib\typescript.js:112475:18) 
    at getNextAffectedFile (D:\dev\redwoodjs\redwood\tasks\framework-tools\node_modules\typescript\lib\typescript.js:112948:51)       
    at getSemanticDiagnosticsOfNextAffectedFile (D:\dev\redwoodjs\redwood\tasks\framework-tools\node_modules\typescript\lib\typescript.js:113578:32)
    at Object.getSemanticDiagnostics (D:\dev\redwoodjs\redwood\tasks\framework-tools\node_modules\typescript\lib\typescript.js:113623:20)
    at getSemanticDiagnostics (D:\dev\redwoodjs\redwood\tasks\framework-tools\node_modules\typescript\lib\typescript.js:116921:62)    
    at executeSteps (D:\dev\redwoodjs\redwood\tasks\framework-tools\node_modules\typescript\lib\typescript.js:117064:25)
    at Object.done (D:\dev\redwoodjs\redwood\tasks\framework-tools\node_modules\typescript\lib\typescript.js:116867:13)
    at build (D:\dev\redwoodjs\redwood\tasks\framework-tools\node_modules\typescript\lib\typescript.js:117536:32)
    at Object.build (D:\dev\redwoodjs\redwood\tasks\framework-tools\node_modules\typescript\lib\typescript.js:117718:101)
error Command failed with exit code 1.

Thinking my framework was corrupted, I've tried blowing away the framework and recloning. The framework builds from a fresh install, but the build fails as soon as I touch a typescript file.

Note, I am on Windows.

@Tobbe
Copy link
Member

Tobbe commented Jul 16, 2021

I had a quick chat to @cjreimer about this on Discord. I'm running into this issue as well on Windows. But it doesn't seem to happen as often to me as it does him.

What works for me is to run yarn build:clean && yarn build. After that I can use yarn rwfw project:sync in my test rw app to test my changes.

@Tobbe
Copy link
Member

Tobbe commented Jul 16, 2021

Not sure if this is relevant, but dropping it here for someone with a better understanding to take a look. The error message is very similar.

cevek/ttypescript#121

If the issue above is relevant, this issue might be solved by this nonara/ts-patch#40

@simoncrypta
Copy link
Collaborator

simoncrypta commented Jul 16, 2021

What works for me is to run yarn build:clean && yarn build.

It didn't work for me, so I tried something a little more radical, and it's work for me :
Delete the repo and re clone.

It's think the problem come from an old typescript definition inside something with .gitinore.

@cjreimer
Copy link
Contributor Author

Update:
OK, thanks to help from @Tobbe, I can now build using the following commands in sequence:

yarn build:clean
yarn build

I believe I need to run the yarn build:clean every time I change a type ... but haven't fully validated that.

I have also played with the following:

Modified \redwood\tasks\framework-tools\package.json
  Added    "ts-patch": "1.4.1",
  Modified     "build:watch": "lerna run build:watch --parallel; tsp --build",

but with mixed success. It might just be a fluke that it worked in some cases.
A v2 of ts-patch is being worked on and might provide some additional options.

@Tobbe
Copy link
Member

Tobbe commented Jul 16, 2021

@cannikin had this happen to him as well, so not a Windows (only) issue

@peterp
Copy link
Contributor

peterp commented Jul 20, 2021

I'm wondering if the --parallel flag on the build command is causing issues. Perhaps the initial build should use the framework level build:js script, and then use the top-level framework build:types command.

In order to test:

execa.sync(
'yarn lerna run build',
['--parallel', `--scope={${packageNames.join(',') + ','}}`],
{
shell: true,
stdio: 'inherit',
cwd: path.resolve(__dirname, '../../'),
}
)

Modify this to run build:js, and then afterwards add:

 execa.sync(
   'yarn build:types',
   {
     shell: true,
     stdio: 'inherit',
     cwd: path.resolve(__dirname, '../../'),
   }
 )

@amorriscode
Copy link
Contributor

I was trying to help @alicelovescake debug her local build and we are both experiencing the same issue (both on Mac).

@peterp I may misunderstood what you meant above but I basically replaced the following:

execa.sync(
'yarn lerna run build',
['--parallel', `--scope={${packageNames.join(',') + ','}}`],
{
shell: true,
stdio: 'inherit',
cwd: path.resolve(__dirname, '../../'),
}
)

with:

  execa.sync('yarn build:js', {
    shell: true,
    stdio: 'inherit',
    cwd: path.resolve(__dirname, '../../'),
  })

  execa.sync('yarn build:types', {
    shell: true,
    stdio: 'inherit',
    cwd: path.resolve(__dirname, '../../'),
  })

to no avail. 😓

@thedavidprice
Copy link
Contributor

The issue here is that the ttsc package we use to build types (and then rebuild) has a bug with the latest typescript version. The resulting behavior is that re-building can often fail. See @Tobbe link above #3053 (comment)

@jtoar has proposed two proposed solutions:

If you want to keep using rwfw for the time being, you'll just need to run build:clean if you run into this error. rwt link is still an option.

@amorriscode
Copy link
Contributor

amorriscode commented Jul 21, 2021

@thedavidprice thanks for sharing those, currently relying on manually running build:clean when working with TypeScript files.

One thing to note: I also see the build error when running rwt link.

@thedavidprice
Copy link
Contributor

One thing to note: I also see the build error when running rwt link.

Ah, that makes sense as it's the same ttsc usage. But is it also blocking the re-build? I've not had these problems myself, so it's been unclear to me where/when it's occuring.

@thedavidprice thedavidprice linked a pull request Jul 21, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants