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

Support for "composite" TS projects / monorepos? #828

Open
transitive-bullshit opened this issue Aug 24, 2020 · 2 comments
Open

Support for "composite" TS projects / monorepos? #828

transitive-bullshit opened this issue Aug 24, 2020 · 2 comments
Labels
scope: upstream Issue in upstream dependency topic: monorepo Related to Lerna monorepos topic: rollup-plugin-typescript2 Issues and PRs relating to rpts2

Comments

@transitive-bullshit
Copy link

transitive-bullshit commented Aug 24, 2020

Current Behavior

composite projects don't appear to be recognized properly. Here's an example top-level composite config from notion-kit:

{
  "compilerOptions": {
    "composite": true
  },
  "files": [],
  "include": [],
  "references": [
    { "path": "./packages/notion-types" },
    { "path": "./packages/notion-utils" },
    { "path": "./packages/notion-client" }
  ]
}

If you run tsdx build on either the root directory containing the composite tsconfig.json, it creates empty output for the composite project.

✓ Building modules 0 ms
✓ Creating entry file 5 ms

If you try to run tsdx build on one of the concrete sub-projects, tsdx fails with an opaque error message:

✓ Creating entry file 735 ms
(typescript) Error: failed to transpile '/Users/tfischer/dev/modules/notion-kit/packages/notion-types/src/index.ts'
Error: failed to transpile '/Users/tfischer/dev/modules/notion-kit/packages/notion-types/src/index.ts'
    at error (/Users/tfischer/.nvm/versions/node/v14.5.0/lib/node_modules/tsdx/node_modules/rollup/dist/shared/node-entry.js:5400:30)
    at throwPluginError (/Users/tfischer/.nvm/versions/node/v14.5.0/lib/node_modules/tsdx/node_modules/rollup/dist/shared/node-entry.js:11878:12)
    at Object.error (/Users/tfischer/.nvm/versions/node/v14.5.0/lib/node_modules/tsdx/node_modules/rollup/dist/shared/node-entry.js:12912:24)
    at Object.error (/Users/tfischer/.nvm/versions/node/v14.5.0/lib/node_modules/tsdx/node_modules/rollup/dist/shared/node-entry.js:12081:38)
    at /Users/tfischer/.nvm/versions/node/v14.5.0/lib/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29036:30
    at TsCache.getCompiled (/Users/tfischer/.nvm/versions/node/v14.5.0/lib/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:24870:33)
    at Object.transform (/Users/tfischer/.nvm/versions/node/v14.5.0/lib/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29022:36)
    at /Users/tfischer/.nvm/versions/node/v14.5.0/lib/node_modules/tsdx/node_modules/rollup/dist/shared/node-entry.js:13117:25

Note that this fairly simple set of composite packages works when compiled directly with tsc.

Versions

node: v14.5.0

"tsdx": "^0.13.3",
"tslib": "^2.0.1",
"typescript": "^4.0.2",

Desired Behavior

I'd love for tsdx to work in this case just like if I ran tsc on this config. E.g., it would build the sub-projects to their respective output folders, taking into account inter-package dependencies.

Who does this impact? Who is this for?

Monorepo package library authors for medium to large-sized projects. People using lerna and composite TS projects.

Describe alternatives you've considered

Currently, I'm just outputting commonjs packages. I really need to output both esm and commonjs modules for these packages, so I'm considering adding a two-phase build for production, but it's awkward and one of the core reasons tsdx was built in the first place.

Also, it's entirely possible that I'm missing something obvious or messing something up on my end.

Thanks!

@agilgur5 agilgur5 added topic: monorepo Related to Lerna monorepos scope: upstream Issue in upstream dependency labels Aug 24, 2020
@agilgur5
Copy link
Collaborator

TSDX uses rollup-plugin-typescript2 under-the-hood. This sounds like and the error looks to be upstream there

@transitive-bullshit
Copy link
Author

Thanks, Anton; seems related: ezolenko/rollup-plugin-typescript2#112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: upstream Issue in upstream dependency topic: monorepo Related to Lerna monorepos topic: rollup-plugin-typescript2 Issues and PRs relating to rpts2
Projects
None yet
Development

No branches or pull requests

2 participants