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 modules paths are being resolved to "matching" user workspace paths causing broken package loading #686

Closed
1 of 5 tasks
thescientist13 opened this issue Aug 6, 2021 · 1 comment · Fixed by #687
Closed
1 of 5 tasks
Assignees
Labels
bug Something isn't working CLI P0 Critical issue that should get addressed ASAP v0.15.1
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Aug 6, 2021

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

After upgrading a handful of projects to Greenwood v0.15.0, the SPA projects, which also happen to be on Lit@2 RC versions, started to experience this issue just when running greenwood develop. Running greenwood serve was fine.
Screen Shot 2021-08-06 at 12 03 30 PM

Seems like a regression then if they were all working fine before? Should try and solve ASAP though along with keeping an eye on #675.

Details

Examples of the issue

Other projects, (those not using Lit@2 anyway), seem to be fine with the upgrade, so there's that going for us at least 😅

@thescientist13 thescientist13 added bug Something isn't working CLI labels Aug 6, 2021
@thescientist13 thescientist13 added this to the 1.0 milestone Aug 6, 2021
@thescientist13 thescientist13 self-assigned this Aug 6, 2021
@thescientist13 thescientist13 changed the title Lit@2 and SPA is unable to to resolve LitElement import in development Lit@2 and SPA is unable to to resolve LitElement import in development Aug 6, 2021
@thescientist13 thescientist13 changed the title Lit@2 and SPA is unable to to resolve LitElement import in development Lit@2 and SPA mode is unable to to resolve LitElement import in development Aug 6, 2021
@thescientist13 thescientist13 added the P0 Critical issue that should get addressed ASAP label Aug 6, 2021
@thescientist13
Copy link
Member Author

OK, found the issue and this is actually related to the refactoring for #520 and more of a coincidence than anything wrong with Lit2@ or SPA mode, per se.

What was happening was in the SPA repo, we had this file structure

src/
  index.js

In index.js we would import Lit as usual

import { html, LitElement } from 'lit';

But what I observed in the browser was that Greenwood was actually resolving node_modules/lit/index.js to src/index.js! 😱
Screen Shot 2021-08-06 at 2 15 21 PM

What was happening was that in plugin-user-workspace, the resolveRelativeUrlmethod from ResourceInterface was chopping down the path such once it cutoff node_modules and lit, it would only leave index.js, which we of course have as a file in our src/ directory, and thus, a (undesired) "match".

resolve nodeModulesUrl @ /Users/owenbuckley/Workspace/analogstudios.net/repo/www.analogstudios.net/node_modules/bootstrap/dist/css/bootstrap.css.map
pshouldServe!!! /Users/owenbuckley/Workspace/analogstudios.net/repo/www.analogstudios.net/node_modules/bootstrap/dist/css/bootstrap.css.map
shouldResolve nodeModulesUrl @ /node_modules/lit/index.js
resolve nodeModulesUrl @ /Users/owenbuckley/Workspace/analogstudios.net/repo/www.analogstudios.net/node_modules/lit/index.js
!workspace URL start! @@@@@@@@@@@ /node_modules/lit/index.js
!workspace URL! @@@@@@@@@@@ /Users/owenbuckley/Workspace/analogstudios.net/repo/www.analogstudios.net/src/index.js
pshouldServe!!! /Users/owenbuckley/Workspace/analogstudios.net/repo/www.analogstudios.net/src/index.js

So basically, easiest solution is to just make plugin-user-workspace ignore anything with node_modules in the URL since it doesn't need to care about anything but files in the user's workspace.

Should find a way to add a spec for this when opening the PR.

@thescientist13 thescientist13 changed the title Lit@2 and SPA mode is unable to to resolve LitElement import in development node modules paths are being resolved to "matching" user workspace paths causing broken package loading Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLI P0 Critical issue that should get addressed ASAP v0.15.1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant