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

Typings problems in rush monorepo (pnpm hard links) #953

Open
Sinled opened this issue Jan 12, 2021 · 7 comments · Fixed by ezolenko/rollup-plugin-typescript2#332
Open
Labels
kind: bug Something isn't working scope: upstream Issue in upstream dependency solution: workaround available There is a workaround available for this issue topic: rollup-plugin-typescript2 Issues and PRs relating to rpts2

Comments

@Sinled
Copy link

Sinled commented Jan 12, 2021

Current Behavior

tsdx build fails inside rush monorepo, when importing third party types and modules

(typescript) Error: /Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/packages/somelib/src/index.tsx(7,10): semantic error TS2305: Module '"../node_modules/office-ui-fabric-react/lib/Styling"' has no exported member 'mergeStyleSets'.
Error: /Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/packages/somelib/src/index.tsx(7,10): semantic error TS2305: Module '"../node_modules/office-ui-fabric-react/lib/Styling"' has no exported member 'mergeStyleSets'.
    at error (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup/1.32.1/node_modules/rollup/dist/shared/node-entry.js:5400:30)
    at throwPluginError (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup/1.32.1/node_modules/rollup/dist/shared/node-entry.js:11878:12)
    at Object.error (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup/1.32.1/node_modules/rollup/dist/shared/node-entry.js:12912:24)
    at Object.error (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup/1.32.1/node_modules/rollup/dist/shared/node-entry.js:12081:38)
    at RollupContext.error (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:17237:30)
    at /Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25033:23
    at arrayEach (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:545:11)
    at Function.forEach (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:9397:14)
    at printDiagnostics (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25006:12)
    at Object.transform (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29277:17)

Expected behavior

build success

Suggested solution(s)

i don't know

Additional context

here is reproduction repo https://github.com/Sinled/test-rushx-tsdx (but it needs rush)

git clone https://github.com/Sinled/test-rushx-tsdx
rush update
rush build

i am not sure if this is tsdx or rush problem,
on the one hand, if i use tsc - instead of tsdx - it builds fine

cd packages/somelib
./node_modules/.bin/tsc --noEmit false 

but on the other - if i install dependencies directly inside package - tsdx also builds ok

Your environment

  System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 459.79 MB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.15.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Browsers:
    Chrome: 87.0.4280.141
    Firefox: 81.0.1
    Safari: 14.0.1

Any ideas how this can be solved?

@agilgur5 agilgur5 added kind: support Asking for support with something or a specific use case topic: monorepo Related to Lerna monorepos labels Jan 12, 2021
@agilgur5
Copy link
Collaborator

agilgur5 commented Jan 12, 2021

(typescript) Error: /Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/packages/somelib/src/index.tsx(7,10): semantic error TS2305: Module '"../node_modules/office-ui-fabric-react/lib/Styling"' has no exported member 'mergeStyleSets'.
Error: /Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/packages/somelib/src/index.tsx(7,10): semantic error TS2305: Module '"../node_modules/office-ui-fabric-react/lib/Styling"' has no exported member 'mergeStyleSets'.

So OUFR has had errors before: #461

I'm not really sure how rush works but if it's lifting OUFR to top-level, you might need to alter your include or typeRoots to also read the top-level typings.

if i use tsc - instead of tsdx - it builds fine

I'm not sure why tsc works though 🤔 Is that the same way you're running tsdx build?

I do see you're using TS v4 for tsc while tsdx is still on TS v3 (see #926 for details and workaround there)

Your environment

Seems like the command may have ran in the wrong directory since tsdx and typescript versions are not shown.

@agilgur5 agilgur5 changed the title Build problems in rush monorepo Typings problems in rush monorepo Jan 12, 2021
@Sinled
Copy link
Author

Sinled commented Jan 13, 2021

@agilgur5 thanks for reply,

i've normalized versions of typescript (explcitly specified 3.9.7 which is used when running tsdx), and tried to run from the same folder

sinled  in ~/dev/Projects/_my/_tmp/test-rushx-tsdx (master●●)
$ cd packages/somelib

sinled in ~/dev/Projects/_my/_tmp/test-rushx-tsdx/packages/somelib (master●●)
$ ./node_modules/.bin/tsc --noEmit false

sinled in ~/dev/Projects/_my/_tmp/test-rushx-tsdx/packages/somelib (master●●)
$ ./node_modules/.bin/tsc -v
Version 3.9.7

sinled at SD-MacBook-Pro in ~/dev/Projects/_my/_tmp/test-rushx-tsdx/packages/somelib (master●●)
$ ./node_modules/.bin/tsdx build
✓ Creating entry file 979 ms
(typescript) Error: /Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/packages/somelib/src/index.tsx(7,10): semantic error TS2305: Module '"../node_modules/office-ui-fabric-react/lib/Styling"' has no exported member 'mergeStyleSets'.
Error: /Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/packages/somelib/src/index.tsx(7,10): semantic error TS2305: Module '"../node_modules/office-ui-fabric-react/lib/Styling"' has no exported member 'mergeStyleSets'.
    at error (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup/1.32.1/node_modules/rollup/dist/shared/node-entry.js:5400:30)
    at throwPluginError (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup/1.32.1/node_modules/rollup/dist/shared/node-entry.js:11878:12)
    at Object.error (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup/1.32.1/node_modules/rollup/dist/shared/node-entry.js:12912:24)
    at Object.error (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup/1.32.1/node_modules/rollup/dist/shared/node-entry.js:12081:38)
    at RollupContext.error (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:17237:30)
    at /Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25033:23
    at arrayEach (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:545:11)
    at Function.forEach (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:9397:14)
    at printDiagnostics (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25006:12)
    at Object.transform (/Users/sinled/dev/Projects/_my/_tmp/test-rushx-tsdx/common/temp/node_modules/.pnpm/registry.npmjs.org/rollup-plugin-typescript2/[email protected][email protected]/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29277:17)

I'm not really sure how rush works but if it's lifting OUFR to top-level, you might need to alter your include or typeRoots to also read the top-level typings.

AFAIK rush hardlinks all dependencies directly to the specific package node_modules

@Sinled
Copy link
Author

Sinled commented Jan 14, 2021

If anyone stumbled upon this,
i've found partial workaround - typecheck with tsc and build with tsdx

"build": "tsc && tsdx build --transpileOnly"

@jessekrubin
Copy link

I am having the same issue with material-ui

@agilgur5 agilgur5 changed the title Typings problems in rush monorepo Typings problems in rush monorepo (pnpm hard links) Mar 6, 2021
@agilgur5 agilgur5 removed the topic: monorepo Related to Lerna monorepos label Mar 6, 2021
@leohxj
Copy link

leohxj commented Apr 7, 2022

I am having the same issue with material-ui

also use rushjs?

@jessekrubin
Copy link

I am having the same issue with material-ui

also use rushjs?

Yes I do!

@agilgur5
Copy link
Collaborator

agilgur5 commented Jun 10, 2022

For reference, I am fairly sure I fixed this upstream in ezolenko/rollup-plugin-typescript2#332, which fixed ezolenko/rollup-plugin-typescript2#234, which is a very similar upstream issue with pnpm symlinks.

To use that in your project, you can set your pnpm overrides to use rollup-plugin-typescript2 0.32.0+:

{
  "pnpm": {
    "overrides": {
      "rollup-plugin-typescript2": "^0.32.0"
    }
  }
}

@agilgur5 agilgur5 added kind: bug Something isn't working scope: upstream Issue in upstream dependency solution: workaround available There is a workaround available for this issue topic: rollup-plugin-typescript2 Issues and PRs relating to rpts2 and removed kind: support Asking for support with something or a specific use case labels Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working scope: upstream Issue in upstream dependency solution: workaround available There is a workaround available for this issue topic: rollup-plugin-typescript2 Issues and PRs relating to rpts2
Projects
None yet
4 participants