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

Fix style modules not being resolved from iframe.html (#266) #268

Merged
merged 8 commits into from Mar 14, 2022
Merged

Fix style modules not being resolved from iframe.html (#266) #268

merged 8 commits into from Mar 14, 2022

Conversation

Dschungelabenteuer
Copy link
Member

Fixes #266

See comment #266 (comment)

  • Upgraded to Vite 2.8.5 to reproduce the issue
  • Updated outdated CONTRIBUTING.md

* Upgrade to Vite 2.8.5 to reproduce the issue
* Updated outdated CONTRIBUTING.md
@IanVS
Copy link
Member

IanVS commented Mar 1, 2022

Thanks for digging into this! It sounds like vite is going to revert for now, and re-introduce this change into 2.9 (vitejs/vite#7136). So, let's hold off on this change for now, until things stabilize a bit. But this seems like a reasonable fix once they do make the change.

@Dschungelabenteuer
Copy link
Member Author

@IanVS I've seen the discussion on Vite's Discord server, should I close this PR or do you want me to update it to include poyoho's implementation of the fix ?

@IanVS
Copy link
Member

IanVS commented Mar 2, 2022

If you're up for using that approach, that would be great! Although, it would be nice if we can use native browser methods and avoid adding a dependency on 'url'. Thanks!

@Dschungelabenteuer
Copy link
Member Author

Hey! Just gave it a try and it seems to be working fine! However, using the native URL API requires:

  • adding "DOM" and "DOM.Iterable" to the tsconfig's lib property
  • a valid URL (which /iframe.html is not), so my first idea was to mock a local file, but I'm not sure this is the best way to go

Any suggestions? See changes

@IanVS
Copy link
Member

IanVS commented Mar 4, 2022

Thanks yet again! I think I need to apologize for sending you down the wrong track. I'm so used to working in the browser that sometimes I forget that most of this code runs in node. And I didn't realize that url is a native node module, so import { parse as parseUrl, URLSearchParams } from 'url'; isn't actually adding a dependency, but rather using the node module. If you used that approach, would it simplify things? Again, sorry for sending you down the wrong track there.

@Dschungelabenteuer
Copy link
Member Author

Dschungelabenteuer commented Mar 5, 2022

Hey Ian! No worries, I should have been able to spot that myself 😄

Node URL module's parseUrl is however marked as deprecated since it's part of the legacy API. Using the WHATWG URL API - which mimics the browser URL API - still requires me to add a fake protocol for the URL to be valid. What would be your take on this?

@IanVS
Copy link
Member

IanVS commented Mar 7, 2022

Ok, bummer. It feels weird to throw a file:// on the string just so we can parse it. What do you think about a simple id.split('?')? And then still using URLSearchParams to deal with the actual search string after the ?.

@Dschungelabenteuer
Copy link
Member Author

Sounds fine to me, here you go 🤞

@IanVS
Copy link
Member

IanVS commented Mar 8, 2022

It looks like another yarn install is needed, there seem to be changes to yarn.lock.

Copy link
Member

@IanVS IanVS left a comment

Choose a reason for hiding this comment

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

Thanks!

@IanVS IanVS merged commit bbfe955 into storybookjs:main Mar 14, 2022
@IanVS
Copy link
Member

IanVS commented Mar 14, 2022

Released in 0.1.19.

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.

iframe style tags are stripped by Vite 2.8.5
2 participants