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

Node.js 13.14.0 'No "exports" main resolved in' @babel/helper-compilation-targets/package.json #900

Closed
JustFly1984 opened this issue Oct 11, 2020 · 6 comments
Labels
kind: support Asking for support with something or a specific use case problem: stale Issue has not been responded to in some time scope: upstream Issue in upstream dependency solution: duplicate This issue or pull request already exists

Comments

@JustFly1984
Copy link

JustFly1984 commented Oct 11, 2020

Current Behavior

Node 13.3.0 - issues on CI/CD browserlist@^4.14.5 dependency of dependency, breaking netlify build of our docs and examples by requiring node engine version newer than 13.7.0

tried both last versions of tsdx@0.13.3 v0.14.0, and experiencing different bugs in CI/CD.

v0.13.3

2:28:59 PM: ✓ Creating entry file 2.1 secs
2:28:59 PM: (babel plugin) Error: No "exports" main resolved in /opt/build/repo/packages/react-google-maps-api-marker-clusterer/node_modules/@babel/helper-compilation-targets/package.json
2:28:59 PM: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main resolved in /opt/build/repo/packages/react-google-maps-api-marker-clusterer/node_modules/@babel/helper-compilation-targets/package.json
2:28:59 PM:     at applyExports (internal/modules/cjs/loader.js:487:9)
2:28:59 PM:     at resolveExports (internal/modules/cjs/loader.js:503:23)
2:28:59 PM:     at Function.Module._findPath (internal/modules/cjs/loader.js:631:31)
2:28:59 PM:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:949:27)
2:28:59 PM:     at Function.Module._load (internal/modules/cjs/loader.js:838:27)
2:28:59 PM:     at Module.require (internal/modules/cjs/loader.js:1022:19)
2:28:59 PM:     at require (internal/modules/cjs/helpers.js:72:18)
2:28:59 PM:     at Object.<anonymous> (/opt/build/repo/packages/react-google-maps-api-marker-clusterer/node_modules/@babel/preset-env/lib/debug.js:8:33)
2:28:59 PM:     at Module._compile (internal/modules/cjs/loader.js:1118:30)
2:28:59 PM:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)

v0.14.0

$ npx tsdx build --name infoBox --format=cjs,esm,umd
✓ Creating entry file 1.3 secs
(typescript) Error: ENOENT: no such file or directory, rename '/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/.cache/rollup-plugin-typescript2/rpt2_2c34c68546ed43d39898c659568a2027b2495a19/code/cache_' -> '/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/.cache/rollup-plugin-typescript2/rpt2_2c34c68546ed43d39898c659568a2027b2495a19/code/cache'
Error: ENOENT: no such file or directory, rename '/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/.cache/rollup-plugin-typescript2/rpt2_2c34c68546ed43d39898c659568a2027b2495a19/code/cache_' -> '/Users/justfly/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/.cache/rollup-plugin-typescript2/rpt2_2c34c68546ed43d39898c659568a2027b2495a19/code/cache'
    at Object.renameSync (fs.js:754:3)
    at RollingCache.roll (/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:24003:12)
    at TsCache.done (/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:24845:24)
    at Object._ongenerate (/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29098:21)
    at Object.generateBundle (/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29076:18)
    at /projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/rollup/dist/shared/node-entry.js:13117:25
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

error Command failed with exit code 1.

Expected behavior

Should build packages with any node version.

Suggested solution(s)

Fix build pipeline

Additional context

You can fork https://github.com/JustFly1984/react-google-maps-api, run nvm use in each package directory separate, to test that each package builds correctly with combination tsdx@0.13.3 and node v13.3.0

But if you run nvm use in the root of repository (v13.14.0), and try to run build scripts from root package.json to build docs and gatsby.js example, you'll get errors^^^

Your environment

System:
    OS: macOS 10.15.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 238.93 MB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 13.14.0 - ~/.nvm/versions/node/v13.14.0/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v13.14.0/bin/npm
  Browsers:
    Chrome: 85.0.4183.121
    Chrome Canary: 88.0.4288.0
    Firefox: 79.0
    Safari: 14.0
  npmPackages:
    tsdx: 0.13.3 => 0.13.3 
    typescript: 4.0.3 => 4.0.3 

PS. My project is in condition where I can build and publish new versions of the lib, but can't deploy docs and examples.

@agilgur5 agilgur5 changed the title Node.js 13.14.0 tsdx build bugs. Node.js 13.14.0 'No "exports" main resolved in' @babel/helper-compilation-targets/package.json Oct 11, 2020
@agilgur5 agilgur5 added scope: upstream Issue in upstream dependency solution: duplicate This issue or pull request already exists labels Oct 11, 2020
@agilgur5
Copy link
Collaborator

agilgur5 commented Oct 11, 2020

@JustFly1984 you've duplicated your own #630 -- as you wrote there the issue is a bug in Node itself, not in TSDX. Since then Node 13 reached EOL in June (c.f. #880). I wouldn't recommend using it as such and in either case it's caused some widespread issues with conditional exports in the community.

Regarding the TSDX v0.14.0 issue, that duplicates #888 and is upstream in rpts2 as the error suggests . #892 duplicated it as well and pointed out it only seems to happen with UMD for some reason (which #898, #896, and this seem to confirm).
#896 is a PR to update to a recently patched version of rpts2 (ezolenko/rollup-plugin-typescript2#243), but as I wrote there, it's not clear to me that that is a root cause fix and I'm also waiting for another new version to be released that includes another bugfix that I personally made upstream (ezolenko/rollup-plugin-typescript2#221).

Please search the issues and upstream before filing new ones.

@JustFly1984
Copy link
Author

@agilgur5 Thank you for fast response!

I can't redeploy docs since June. My lib is used by 2500 projects, and growing. I want to start recording video tutorials.
Can you please estimate how long it will take for next release? Would love to update node to latest 14 version. If you can confirm that tsdx@0.14.0 supports node@14, I will test node 14. Still not sure that gatsby.js supports node 14 though.

Have a great day!

@agilgur5
Copy link
Collaborator

agilgur5 commented Oct 11, 2020

Can you please estimate how long it will take for next release?

ezolenko/rollup-plugin-typescript2#221 and #823 were the last two things I was looking to get in before releasing TSDX v0.14.1, but given ezolenko/rollup-plugin-typescript2#221 hasn't been released in over a week since merging and this UMD cache issue seems somewhat widespread, I was considering cutting a release for TSDX v0.14.1 early, possibly today.

But you should be able to use TSDX v0.13.3 fine. This bug is a bug in EOL Node 13, not in TSDX.

Still not sure that gatsby.js supports node 14 though

I'd be surprised if it doesn't. A large proportion of developers are already using Node 14.
You can also downgrade to Node 12. Not sure if you're using some new Node feature or something.

If you can confirm that tsdx@0.14.0 supports node@14

Yes, the internal PR I linked to regarding Node 13, #880, upgraded TSDX's internal CI matrix to use Node 14. So can confirm it supports Node 14. I think a number of users have confirmed that as well.

@JustFly1984
Copy link
Author

JustFly1984 commented Oct 12, 2020

@agilgur5 I have tested tsdx@0.13.3 and tsdx@0.14.0 with node 14.13.1 and it fails the build with same error

0.13.3

(babel plugin) Error: No "exports" main defined in /projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/@babel/helper-compilation-targets/package.json
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/@babel/helper-compilation-targets/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:513:3)
    at resolveExports (internal/modules/cjs/loader.js:432:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:472:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/@babel/preset-env/lib/debug.js:8:33)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)

0.14.0

(typescript) Error: ENOENT: no such file or directory, rename /projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/.cache/rollup-plugin-typescript2/rpt2_2c34c68546ed43d39898c659568a2027b2495a19/code/cache_' -> '/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/.cache/rollup-plugin-typescript2/rpt2_2c34c68546ed43d39898c659568a2027b2495a19/code/cache'
Error: ENOENT: no such file or directory, rename /projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/.cache/rollup-plugin-typescript2/rpt2_2c34c68546ed43d39898c659568a2027b2495a19/code/cache_' -> '/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/.cache/rollup-plugin-typescript2/rpt2_2c34c68546ed43d39898c659568a2027b2495a19/code/cache'
    at Object.renameSync (fs.js:770:3)
    at RollingCache.roll (/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:24003:12)
    at TsCache.done (/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:24845:24)
    at Object._ongenerate (/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29098:21)
    at Object.generateBundle (/projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29076:18)
    at /projects/react-google-maps-api/packages/react-google-maps-api-infobox/node_modules/rollup/dist/shared/node-entry.js:13117:25
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

error Command failed with exit code 1.

@agilgur5
Copy link
Collaborator

agilgur5 commented Oct 12, 2020

0.13.3

Well actually this is a slightly different error than the one in Node 13, it says "defined" instead of "resolved".
In any case, please read the issue you duplicated -- your own #630 -- as this is either a bug in Babel or in Node or both. It's quite upstream of TSDX and hit by 1000s of people, probably the most widespread Node bug I've seen. It's not in or specific to TSDX, so this isn't the right place.

I looked into it for you and the upstream issue you linked to indeed suggests both are to blame and that @babel/helper-compilation-targets@7.8.3 has this bug (per babel/babel#11216 (comment)). Your yarn.lock pins that exact version. You can upgrade it or @babel/preset-env in your lockfile to fix it.

0.14.0

Yes, I've already written and linked to where this error comes from and which issues it duplicates and which PR solves it. There's quite a lot of details in those issues. That's not unique to Node version.

If you pass this error, you might still hit the error above. Though TSDX v0.14.0 upgraded the internal @babel/preset-env (#838 ), so it may indirectly change your yarn.lock and indirectly upgrade @babel/helper-compilation-targets to a newer version that doesn't have this bug.

@agilgur5 agilgur5 added the kind: support Asking for support with something or a specific use case label Oct 12, 2020
@agilgur5
Copy link
Collaborator

agilgur5 commented Oct 13, 2020

The v0.14.0 cache issue has been fixed with #896 / ezolenko/rollup-plugin-typescript2#243 and just released in v0.14.1.

You should be able to get v0.13.3 to work fine though, as I wrote above that seems to be directly due to your yarn.lock pin, and not because of something in TSDX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: support Asking for support with something or a specific use case problem: stale Issue has not been responded to in some time scope: upstream Issue in upstream dependency solution: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants