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

Correctly resolve virtual resource loader path on Windows #130

Merged
merged 15 commits into from
Mar 29, 2023

Conversation

mrm007
Copy link
Contributor

@mrm007 mrm007 commented Mar 28, 2023

Follow-up from this Slack thread where the developer was on Windows and was seeing errors. The errors were caused by the way the virtual-resource-loader path is resolved on Windows.

The solution is to use stringifyRequest from loader-utils.

I also changed all fixtures to depend on internal packages with workspace:* because I lost too much time debugging why my changes didn't have an effect. I pulled master and after pnpm install fixtures had a newer version of @vocab/* packages than what I was developing on locally.

Error log
$ sku build
Running Vocab compile
Using browser-only version of superagent in non-browser environment
Webpack Bundle Analyzer saved report to C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\report\client.html
client:
  ERROR in  (./src/components/shared/Nudge/nudges/JobApplyNudge/.vocab/translations.json-en-virtual.json!=!C:UsersaiqbalOneDrive - SEEKDocumentsSeekonline-identity-auth0-hosted-pages
  ode_modules♂irtual-resource-loaderdist♂irtual-resource-loader.cjs.js?source=eyJBcHBseWluZyBmb3IiOiJBcHBseWluZyBmb3IifQ==!)
  Module build failed: UnhandledSchemeError: Reading from "C:UsersaiqbalOneDrive - SEEKDocumentsSeekonline-identity-auth0-hosted-pages
  ode_modules♂irtual-resource-loaderdist♂irtual-resource-loader.cjs.js?source=eyJBcHBseWluZyBmb3IiOiJBcHBseWluZyBmb3IifQ==!" is not handled by plugins (Unhandled scheme).
  Webpack supports "data:" and "file:" URIs by default.
  You may need an additional plugin to handle "c:" URIs.
      at C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:834:25
      at Hook.eval [as callAsync] (eval at create (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anon
ymous>:6:1)
      at Object.processResource (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:831:8)
      at processResource (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\loader-runner\lib\LoaderRunner.js:220:11)
      at iteratePitchingLoaders (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\loader-runner\lib\LoaderRunner.js:171:10)
      at runLoaders (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\loader-runner\lib\LoaderRunner.js:398:2)
      at NormalModule._doBuild (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:821:3)
      at NormalModule.build (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:965:15)
      at C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\Compilation.js:1371:12
      at NormalModule.needBuild (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:1253:32)
      at Compilation._buildModule (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\Compilation.js:1352:10)
      at C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\util\AsyncQueue.js:303:10
      at Hook.eval [as callAsync] (eval at create (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anon
ymous>:6:1)
      at AsyncQueue._startProcessing (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\util\AsyncQueue.js:293:26)
      at AsyncQueue._ensureProcessing (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\util\AsyncQueue.js:280:12)
      at processImmediate (node:internal/timers:466:21)
   @ ./src/components/shared/Nudge/nudges/JobApplyNudge/.vocab/index.ts 5:31-299 14:31-302 17:31-302 20:31-302 23:31-302 26:31-302 29:31-302 32:31-302 35:31-302 35:310-38:5 32:310-35:5 29:310-32:5 26:310-29:5 23
:310-26:5 20:310-23:5 17:310-20:5 14:310-17:5 5:307-8:5
   @ ./src/components/shared/Nudge/nudges/JobApplyNudge/JobApplyNudge.tsx 5:0-36 8:41-53
   @ ./src/components/shared/Nudge/Nudge.tsx 18:0-65 42:29-42
   @ ./src/components/pages/LoginPage/ForgotPasswordForm/ForgotPasswordForm.tsx 29:0-48 144:51-56
   @ ./src/components/AppRoutes.tsx 7:0-89 35:31-49
   @ ./src/components/App.tsx 19:0-36 84:60-69
   @ ./src/client.tsx 5:0-35 25:78-81
   @ ./node_modules/sku/entry/client/index.js

  ERROR in  (./src/components/shared/Nudge/nudges/JobApplyNudge/.vocab/translations.json-id-virtual.json!=!C:UsersaiqbalOneDrive - SEEKDocumentsSeekonline-identity-auth0-hosted-pages
  ode_modules♂irtual-resource-loaderdist♂irtual-resource-loader.cjs.js?source=eyJBcHBseWluZyBmb3IiOiJNZWxhbWFyIHVudHVrIn0=!)
  Module build failed: UnhandledSchemeError: Reading from "C:UsersaiqbalOneDrive - SEEKDocumentsSeekonline-identity-auth0-hosted-pages
  ode_modules♂irtual-resource-loaderdist♂irtual-resource-loader.cjs.js?source=eyJBcHBseWluZyBmb3IiOiJNZWxhbWFyIHVudHVrIn0=!" is not handled by plugins (Unhandled scheme).
  Webpack supports "data:" and "file:" URIs by default.
  You may need an additional plugin to handle "c:" URIs.
      at C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:834:25
      at Hook.eval [as callAsync] (eval at create (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anon
ymous>:6:1)
      at Object.processResource (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:831:8)
      at processResource (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\loader-runner\lib\LoaderRunner.js:220:11)
      at iteratePitchingLoaders (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\loader-runner\lib\LoaderRunner.js:171:10)
      at runLoaders (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\loader-runner\lib\LoaderRunner.js:398:2)
      at NormalModule._doBuild (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:821:3)
      at NormalModule.build (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:965:15)
      at C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\Compilation.js:1371:12
      at NormalModule.needBuild (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:1253:32)
      at Compilation._buildModule (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\Compilation.js:1352:10)
      at C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\util\AsyncQueue.js:303:10
      at Hook.eval [as callAsync] (eval at create (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anon
ymous>:6:1)
      at AsyncQueue._startProcessing (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\util\AsyncQueue.js:293:26)
      at AsyncQueue._ensureProcessing (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\util\AsyncQueue.js:280:12)
      at processImmediate (node:internal/timers:466:21)
   @ ./src/components/shared/Nudge/nudges/JobApplyNudge/.vocab/index.ts 8:28-296 38:31-302 38:310-41:5 8:304-11:5
   @ ./src/components/shared/Nudge/nudges/JobApplyNudge/JobApplyNudge.tsx 5:0-36 8:41-53
   @ ./src/components/shared/Nudge/Nudge.tsx 18:0-65 42:29-42
   @ ./src/components/pages/LoginPage/ForgotPasswordForm/ForgotPasswordForm.tsx 29:0-48 144:51-56
   @ ./src/components/AppRoutes.tsx 7:0-89 35:31-49
   @ ./src/components/App.tsx 19:0-36 84:60-69
   @ ./src/client.tsx 5:0-35 25:78-81
   @ ./node_modules/sku/entry/client/index.js

  ERROR in  (./src/components/shared/Nudge/nudges/JobApplyNudge/.vocab/translations.json-th-virtual.json!=!C:UsersaiqbalOneDrive - SEEKDocumentsSeekonline-identity-auth0-hosted-pages
  ode_modules♂irtual-resource-loaderdist♂irtual-resource-loader.cjs.js?source=eyJBcHBseWluZyBmb3IiOiLguKrguKHguLHguITguKPguIfguLLguJnguJXguLPguYHguKvguJnguYjguIcifQ==!)
  Module build failed: UnhandledSchemeError: Reading from "C:UsersaiqbalOneDrive - SEEKDocumentsSeekonline-identity-auth0-hosted-pages
  ode_modules♂irtual-resource-loaderdist♂irtual-resource-loader.cjs.js?source=eyJBcHBseWluZyBmb3IiOiLguKrguKHguLHguITguKPguIfguLLguJnguJXguLPguYHguKvguJnguYjguIcifQ==!" is not handled by plugins (Unhandled schem
e).
  Webpack supports "data:" and "file:" URIs by default.
  You may need an additional plugin to handle "c:" URIs.
      at C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:834:25
      at Hook.eval [as callAsync] (eval at create (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anon
ymous>:6:1)
      at Object.processResource (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:831:8)
      at processResource (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\loader-runner\lib\LoaderRunner.js:220:11)
      at iteratePitchingLoaders (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\loader-runner\lib\LoaderRunner.js:171:10)
      at runLoaders (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\loader-runner\lib\LoaderRunner.js:398:2)
      at NormalModule._doBuild (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:821:3)
      at NormalModule.build (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:965:15)
      at C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\Compilation.js:1371:12
      at NormalModule.needBuild (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\NormalModule.js:1253:32)
      at Compilation._buildModule (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\Compilation.js:1352:10)
      at C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\util\AsyncQueue.js:303:10
      at Hook.eval [as callAsync] (eval at create (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anon
ymous>:6:1)
      at AsyncQueue._startProcessing (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\util\AsyncQueue.js:293:26)
      at AsyncQueue._ensureProcessing (C:\Users\aiqbal\OneDrive - SEEK\Documents\Seek\online-identity-auth0-hosted-pages\node_modules\webpack\lib\util\AsyncQueue.js:280:12)
      at processImmediate (node:internal/timers:466:21)
   @ ./src/components/shared/Nudge/nudges/JobApplyNudge/.vocab/index.ts 11:28-340 41:31-346 41:354-44:5 11:348-14:5
   @ ./src/components/shared/Nudge/nudges/JobApplyNudge/JobApplyNudge.tsx 5:0-36 8:41-53
   @ ./src/components/shared/Nudge/Nudge.tsx 18:0-65 42:29-42
   @ ./src/components/pages/LoginPage/ForgotPasswordForm/ForgotPasswordForm.tsx 29:0-48 144:51-56
   @ ./src/components/AppRoutes.tsx 7:0-89 35:31-49
   @ ./src/components/App.tsx 19:0-36 84:60-69
   @ ./src/client.tsx 5:0-35 25:78-81
   @ ./node_modules/sku/entry/client/index.js

etc.

@mrm007 mrm007 requested a review from a team as a code owner March 28, 2023 04:49
@changeset-bot
Copy link

changeset-bot bot commented Mar 28, 2023

🦋 Changeset detected

Latest commit: 5204745

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@vocab/webpack Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

askoufis
askoufis previously approved these changes Mar 28, 2023
packages/webpack/src/loader.ts Outdated Show resolved Hide resolved
packages/webpack/src/loader.ts Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Comment on lines 52 to 53
"peerDependencies": {
"webpack": "^5.27.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Leaving this decision as a comment so there's a record of it somewhere public.

Vocab has very few consumers outside of SEEK, and @vocab/webpack's only dependent is sku which is already using a newer version of webpack than this. So, in the interest of not needing to do any work in sku to support a new major version, we've decided not to do a breaking change despite adding a peer dependency on webpack (that should've already been there).

@mrm007 mrm007 requested a review from askoufis March 29, 2023 03:16
Comment on lines -73 to -76
// @ts-expect-error We define our own loader context type, getOptions expects
// webpack's LoaderContext type, but it's missing the target field
// https://github.com/webpack/webpack/issues/16753
const config = getOptions(this) as unknown as UserConfig;
Copy link
Contributor

@askoufis askoufis Mar 29, 2023

Choose a reason for hiding this comment

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

This fix was only released in webpack 5.76, does this still typecheck with wepack<5.76?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works with the Webpack installed in this project. But good catch, the peer dependency should be set to ^5.37.0 webpack/webpack#13164

Copy link
Contributor

Choose a reason for hiding this comment

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

But we use this.target a few lines down, that would still fail to typecheck below 5.76 right? Don't really want to set a 5.76 peer dep on this package, though we could do it with a sku update i suppose.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just using it as a dev dep, 5.76 isn't required for consumers 🤦

@mrm007 mrm007 merged commit 2bac4f2 into master Mar 29, 2023
@mrm007 mrm007 deleted the fix-loader-windows branch March 29, 2023 03:54
@seek-oss-ci seek-oss-ci mentioned this pull request Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants