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

[BUG] plugin-typescript not working with project references #1466

Closed
deeeed opened this issue Mar 29, 2023 · 5 comments
Closed

[BUG] plugin-typescript not working with project references #1466

deeeed opened this issue Mar 29, 2023 · 5 comments

Comments

@deeeed
Copy link

deeeed commented Mar 29, 2023

Typescript plugin errors while using project references.

Expected Behavior

Rollup typescript should work similarly to tsc when compiling with project references.

Actual Behavior

Currently it seems to fail when asserting the referred projects.

Additional Information

I have been trying to work with a yarn3 monorepo and setup paths mapping and project references with typescript but rollup is failing to compile.

An example repro is available at demo project

I created two config files to illustrate the issue. Only difference is in the typescript configuration:

  • error happens because of project references when called from @rollup/typescript-plugin
{
    // "extends": "../../tsconfig.json",
    "compilerOptions": {
        "composite": true,
        "rootDir": ".",
        "outDir": "./dist",
        "paths": {
            "@demo/common": ["../common/src"]
        }
    },
    "include": ["src"],
    "references": [
        {
            "path": "../common"
        }
    ]
}
  • compile correctly without project references
{
    // "extends": "../../tsconfig.json",
    "compilerOptions": {
        "composite": true,
        "rootDir": ".",
        "outDir": "./dist",
        "paths": {
            "@demo/common": ["../common/src"]
        }
    },
    "include": ["src"],
    "references": []
    // "references": [
    //     {
    //         "path": "../common"
    //     }
    // ]
}

Basic project structure for the reproduction

├── package.json
├── packages
│   ├── app
│   │   ├── package.json
│   │   ├── rollup.config.js
│   │   ├── rollup.config.ok.js
│   │   ├── src
│   │   │   ├── app.ts
│   │   │   └── types
│   │   │       └── SDKLoggingOptions.ts
│   │   ├── tsconfig.json
│   │   ├── tsconfig.ok.json
│   │   └── tsconfig.tsbuildinfo
│   └── common
│       ├── package.json
│       ├── src
│       │   ├── AutoConnectOptions.ts
│       │   ├── ConnectionStatus.ts
│       │   └── common.ts
│       ├── tsconfig.json
│       └── tsconfig.tsbuildinfo
├── tsconfig.json
├── tsconfig.tsbuildinfo
└── yarn.lock
# Make sure you can use yarn berry to check the example (similar issue occurs with previous yarn version)
 git clone https://github.com/deeeed/demo-yarn-workspaces.git
 cd demo-yarn-workspaces
 yarn
 cd packages/app
  • Failed rollup config
~/Projects/demo-yarn-workspaces/packages/app  v16.16.0
▷ yarn build                                                                                                                                                                                    ! main 

src/app.ts → dist...
[!] (plugin typescript) Error: Debug Failure. False expression.
    at updateExtendedConfigFilesWatches (/Users/test/Projects/demo-yarn-workspaces/node_modules/typescript/lib/typescript.js:123065:13)
    at watchReferencedProject (/Users/test/Projects/demo-yarn-workspaces/node_modules/typescript/lib/typescript.js:123160:7)
    at Object.getParsedCommandLine (/Users/test/Projects/demo-yarn-workspaces/node_modules/typescript/lib/typescript.js:122961:7)
    at parseProjectReferenceConfigFile (/Users/test/Projects/demo-yarn-workspaces/node_modules/typescript/lib/typescript.js:117987:28)
    at Array.map (<anonymous>)
    at createProgram (/Users/test/Projects/demo-yarn-workspaces/node_modules/typescript/lib/typescript.js:116040:57)
    at getBuilderCreationParameters (/Users/test/Projects/demo-yarn-workspaces/node_modules/typescript/lib/typescript.js:120378:20)
    at createEmitAndSemanticDiagnosticsBuilderProgram (/Users/test/Projects/demo-yarn-workspaces/node_modules/typescript/lib/typescript.js:120904:83)
    at createNewProgram (/Users/test/Projects/demo-yarn-workspaces/node_modules/typescript/lib/typescript.js:122702:24)
    at synchronizeProgram (/Users/test/Projects/demo-yarn-workspaces/node_modules/typescript/lib/typescript.js:122676:9)
                                                                                                                                                                                                        
~/Projects/demo-yarn-workspaces/packages/app  v16.16.0
▷     
  • Working rollup config without references
~/Projects/demo-yarn-workspaces/packages/app  v16.16.0
▷ yarn build:ok                                                                                                                                                                                 ! main 

src/app.ts → dist...
(!) Unresolved dependencies
https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency
@demo/common (imported by "src/app.ts")
(!) Mixing named and default exports
https://rollupjs.org/configuration-options/#output-exports
The following entry modules are using named and default exports together:
src/app.ts

Consumers of your bundle will have to use chunk.default to access their default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
created dist in 537ms
                                                                                                                                                                                                        
~/Projects/demo-yarn-workspaces/packages/app  v16.16.0
@filiptammergard
Copy link

Related to #1036?

@stale stale bot added the x⁷ ⋅ stale label Jun 10, 2023
@stale
Copy link

stale bot commented Jun 11, 2023

Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it.

@stale stale bot closed this as completed Jun 11, 2023
@lavcraft
Copy link

@filiptammergard yes, it is :) But all issues related to project references support look abandoned :(

I try to use rollup-typescrip2 plugin. At simple cases it works well, but i have problem in my cases - ezolenko/rollup-plugin-typescript2#454

@filiptammergard
Copy link

@lavcraft Too bad. Maybe something we could get a PR up for?

@lavcraft
Copy link

@filiptammergard now i don't have appropriate fixes and try to fix my problem with rpt2 plugin instead of this. PR is good, but need a time for unsterstand this project and tsc project references particularities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants