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

pnp-webpack-plugin cannot work outside of pnp runtime. #32

Closed
missing1984 opened this issue Mar 19, 2021 · 0 comments · Fixed by #37 or webpack/enhanced-resolve#301
Closed

pnp-webpack-plugin cannot work outside of pnp runtime. #32

missing1984 opened this issue Mar 19, 2021 · 0 comments · Fixed by #37 or webpack/enhanced-resolve#301

Comments

@missing1984
Copy link
Contributor

Context

Trying to add yarn pnp support to cypress and ran into following error

**Details:** Error: Cannot find module 'pnpapi'
Require stack:
- /Users/mluo/Library/Caches/Cypress/6.6.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/pnp-webpack-plugin/index.js
- /Users/mluo/Library/Caches/Cypress/6.6.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/webpack-batteries-included-preprocessor/index.js
- /Users/mluo/Library/Caches/Cypress/6.6.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js
- /Users/mluo/Library/Caches/Cypress/6.6.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/index.js
Require stack:
- /Users/mluo/Library/Caches/Cypress/6.6.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/pnp-webpack-plugin/index.js
- /Users/mluo/Library/Caches/Cypress/6.6.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/webpack-batteries-included-preprocessor/index.js
- /Users/mluo/Library/Caches/Cypress/6.6.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js
- /Users/mluo/Library/Caches/Cypress/6.6.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:972:15)
    at Function.external_module_.Module._resolveFilename (/Users/mluo/workspace/gitlab/ui-platform/projects/apps/px/.pnp.js:38306:54)
    at Module._load (internal/modules/cjs/loader.js:848:27)
    at external_module_.Module._load (/Users/mluo/workspace/gitlab/ui-platform/projects/apps/px/.pnp.js:38162:36)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
    at Module.require (internal/modules/cjs/loader.js:1032:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at getSourceLocation (/Users/mluo/Library/Caches/Cypress/6.6.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/pnp-webpack-plugin/index.js:39:15)
    at makeResolver (/Users/mluo/Library/Caches/Cypress/6.6.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/pnp-webpack-plugin/index.js:53:26)
    at Object.<anonymous> (/Users/mluo/Library/Caches/Cypress/6.6.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/pnp-webpack-plugin/index.js:147:10)
    at Module._compile (internal/modules/cjs/loader.js:1152:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1173:10)
    at Module.load (internal/modules/cjs/loader.js:992:32)
    at Module._load (internal/modules/cjs/loader.js:885:14)
    at external_module_.Module._load (/Users/mluo/workspace/gitlab/ui-platform/projects/apps/px/.pnp.js:38162:36)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12738)

Cypress server (an Electron app)is forking a new process to compile plugins from user project, however, the webpack config and compile code live with Cypress app.

After chatting with merceyz in channel, it looks like pnp-webpack-plugin assumes it been located within the pnp project and it's not the case here.

https://discord.com/channels/226791405589233664/654372321225605128/822584013377241108

Would that be possible to port what we've done in webpack 5/enhanced-resolve so pnp-webpack-plugin can work in that scenario.

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