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

test: Add failing tests for async css modules #6044

Closed
wants to merge 2 commits into from

Conversation

IanVS
Copy link
Contributor

@IanVS IanVS commented Dec 9, 2021

Description

This adds a failing test for #3924, to hopefully help someone who knows more than I do actually fix the bug.

Additional context

If someone can point me in the right direction I can take a crack at fixing this.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@IanVS
Copy link
Contributor Author

IanVS commented Dec 22, 2021

I think @patak-dev's post sheds some light on what might be going on here: https://patak.dev/vite/build.html#_14-vite-css-post. Specifically, this part:

This plugin will transform dynamic imports using this helper. The following

import('./async.js')

will be transpiled into

preload(
 () => import('/assets/async.js),
 ['/assets/async.css','/assets/async-dep.js']
)

It seems like what is needed is a more robust tree-walking which does not simply create a .css file for each dynamically imported asset, but rather builds up a list of files that need to be created, and then actually inject them in the correct order.

So, if we have moduleA and common which both have css modules, and might look like this:

// moduleA.js
import 'common'
import styles from 'moduleA.module.css'

// common.js
import styles from 'common.module.css'

Currently the import order is:

moduleA.js
moduleA.css
common.js
common.css

But in reality what we need is:

moduleA.js
common.js
common.css
moduleA.css

poyoho added a commit to poyoho/vite that referenced this pull request Jan 6, 2022
@poyoho poyoho mentioned this pull request Jul 21, 2022
12 tasks
@IanVS
Copy link
Contributor Author

IanVS commented Aug 11, 2022

The latest work on this is being done in #9278.

@IanVS IanVS closed this Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants