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

7.0.0 pnp support #18461

Merged
merged 11 commits into from
Jun 14, 2022
Merged

7.0.0 pnp support #18461

merged 11 commits into from
Jun 14, 2022

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Jun 10, 2022

So in order for pnp to work, we need to ensure all dependencies exist in the context they are required in.
This achieves that by using require.resolve.

The way i achieve the above is by generating the proper code into main.js.
This is ugly, but right now I just want to ensure it actually works in pnp mode.

If it does, I plan to either:

  • only do this when pnp mode is active
  • OR load presets (includes main.js) via some sort of interpreter/loader and modify the code before executing.

@nx-cloud
Copy link

nx-cloud bot commented Jun 10, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit d639aff. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@ndelangen
Copy link
Member Author

ndelangen commented Jun 10, 2022

If this is succesful, I'm planning of writing a auto-migration to migrate the user's main.js before running storybook.
The code isn't quite majetic looking...

Alternatively I could investigate into:
What if I generated a file like:

const path = require('path');

module.exports = {
  '@storybook/react-webpack5': path.dirname(require.resolve(path.join(''@storybook/react-webpack5', 'package.json'))),
  // ... more addons and frameworks here
}

And used that file to help resolve dependencies...
That would keep main.js pretty clean, but of course it would break really fast if not kept up to date. And it would also have to exist in the user's configDir anyway...

@ndelangen ndelangen marked this pull request as draft June 10, 2022 14:59
@ndelangen ndelangen self-assigned this Jun 10, 2022
@ndelangen ndelangen added the maintenance User-facing maintenance tasks label Jun 10, 2022
@ndelangen ndelangen changed the title this is a bit of a experiment tbh 7.0.0 pnp support Jun 13, 2022
@@ -60,9 +60,14 @@ export const exec = async (
logger.debug(command);
return new Promise((resolve, reject) => {
const defaultOptions: ExecOptions = {
silent: true,
silent: false,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this

...defaultOptions,
...options,
async: true,
silent: false,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this

@codecov
Copy link

codecov bot commented Jun 14, 2022

Codecov Report

Merging #18461 (d639aff) into future/base (cef1f01) will decrease coverage by 0.01%.
The diff coverage is 11.11%.

@@               Coverage Diff               @@
##           future/base   #18461      +/-   ##
===============================================
- Coverage        30.76%   30.74%   -0.02%     
===============================================
  Files              799      798       -1     
  Lines            17076    17079       +3     
  Branches          3526     3526              
===============================================
- Hits              5253     5251       -2     
- Misses           11398    11403       +5     
  Partials           425      425              
Impacted Files Coverage Δ
frameworks/angular/src/preset.ts 0.00% <0.00%> (ø)
frameworks/react-webpack5/src/preset.ts 0.00% <0.00%> (ø)
frameworks/vue-webpack5/src/preset.ts 0.00% <0.00%> (ø)
...ilder-webpack5/src/preview/babel-loader-preview.ts 0.00% <0.00%> (ø)
...lder-webpack5/src/preview/iframe-webpack.config.ts 0.00% <0.00%> (ø)
lib/cli/src/automigrate/index.ts 3.03% <0.00%> (-0.20%) ⬇️
lib/cli/src/repro-generators/scripts.ts 0.00% <0.00%> (ø)
lib/core-server/src/utils/get-builders.ts 60.00% <100.00%> (-6.67%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cef1f01...d639aff. Read the comment docs.

Base automatically changed from future/bench-playright-test to future/base June 14, 2022 11:05
@ndelangen ndelangen marked this pull request as ready for review June 14, 2022 11:06
@ndelangen ndelangen merged commit 9f54bbd into future/base Jun 14, 2022
@ndelangen ndelangen deleted the future/pnp-proof-main branch June 14, 2022 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility with other tools maintenance User-facing maintenance tasks yarn / npm Yarn / npm acting weird
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants