analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.5k stars 240 forks source link

[BUG] vite optimize error #78

Closed Yberion closed 2 years ago

Yberion commented 2 years ago

Please provide the environment you discovered this bug in.

You just need to create a new analog project on stackblitz and you will face the problem (use the link from de readme)

Here is a repro:

https://stackblitz.com/edit/github-cjjxe9

Which area/package is the issue in?

create-analog

Description

Since #76, there is an error on the postinstall script vite optimize.

If I revert the PR I will face back the problem (#75) that should've been fixed by the PR.

Please provide the exception or error you saw

PS D:\GitHub\analog\analog-project> npm i

> analog-project@0.0.0 postinstall
> vite optimize

X [ERROR] [plugin angular-compiler] TS2593: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.

    src/app/app.component.spec.ts:5:0:
      5 │ describe('AppComponent', () => {
        ╵ ~~~~~~~~

X [ERROR] [plugin angular-compiler] TS2304: Cannot find name 'beforeEach'.

    src/app/app.component.spec.ts:6:2:
      6 │   beforeEach(async () => {
        ╵   ~~~~~~~~~~

X [ERROR] [plugin angular-compiler] TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.

    src/app/app.component.spec.ts:15:2:
      15 │   it('should create the app', () => {
         ╵   ~~

X [ERROR] [plugin angular-compiler] TS2304: Cannot find name 'expect'.

    src/app/app.component.spec.ts:18:4:
      18 │     expect(app).toBeTruthy();
         ╵     ~~~~~~

X [ERROR] [plugin angular-compiler] TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.

    src/app/app.component.spec.ts:21:2:
      21 │   it(`should have an initial count of 0`, () => {
         ╵   ~~

X [ERROR] [plugin angular-compiler] TS2304: Cannot find name 'expect'.

    src/app/app.component.spec.ts:24:4:
      24 │     expect(app.count).toEqual(0);
         ╵     ~~~~~~

X [ERROR] [plugin angular-compiler] TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.

    src/app/app.component.spec.ts:27:2:
      27 │   it('should render title', () => {
         ╵   ~~

X [ERROR] [plugin angular-compiler] TS2304: Cannot find name 'expect'.

src/app/app.component.spec.ts:18:4: ERROR: [plugin: angular-compiler] TS2304: Cannot find name 'expect'.
src/app/app.component.spec.ts:21:2: ERROR: [plugin: angular-compiler] TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.
...
    at failureErrorWithLog (D:\GitHub\analog\analog-project\node_modules\vite\node_modules\esbuild\lib\main.js:1624:15)
    at D:\GitHub\analog\analog-project\node_modules\vite\node_modules\esbuild\lib\main.js:1266:28
    at processTicksAndRejections (node:internal/process/task_queues:96:5)npm ERR! code 1
npm ERR! path D:\GitHub\analog\analog-project
npm ERR! command failednpm ERR! command C:\Windows\system32\cmd.exe /d /s /c vite optimize

npm ERR! A complete log of this run can be found in:npm ERR!     C:\Users\Yberion\AppData\Local\npm-cache\_logs\2022-09-03T20_50_41_221Z-debug-0.log
PS D:\GitHub\analog\analog-project>

Other information

No response

I would be willing to submit a PR to fix this issue

Yberion commented 2 years ago

Problem fixed with https://github.com/analogjs/analog/commit/78feab26df5d05095b24f6b0ecf49b1d04ae452e, thank you @brandonroberts :)