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

[BUG] CSS Modules support broken in 3.3.3 #3226

Closed
sminnee opened this issue Apr 29, 2021 · 5 comments
Closed

[BUG] CSS Modules support broken in 3.3.3 #3226

sminnee opened this issue Apr 29, 2021 · 5 comments
Assignees

Comments

@sminnee
Copy link

sminnee commented Apr 29, 2021

Describe the bug

The JSON payload of CSS modules is empty in 3.3.3+

I've downloiaded

It seems to be this commit 8329444

To Reproduce

Run snowpack with a module

/** block.module.css *.
:root {
  --some-color: red;
}

.edit {
  color: var(--some-color);
  font: sans-serif;
  width: 100%;
}

.view {
  color: var(--some-color);
  font: sans-serif;
  width: 100%;
}

Import in a JS file

Observe the block.modules.css.proxy.js content:

export let code = ".__edit_162wa_5_10gxy_1 {\n  color: red;\n  font: sans-serif;\n  width: 100%;\n}\n\n.__view_162wa_11_10gxy_7 {\n  color: red;\n  font: sans-serif;\n  width: 100%;\n}\n";
let json = {};
export default json;

import * as __SNOWPACK_HMR_API__ from '/_snowpack/hmr-client.js';
import.meta.hot = __SNOWPACK_HMR_API__.createHotContext(import.meta.url);

// [snowpack] add styles to the page (skip if no document exists)
if (typeof document !== 'undefined') {
  import.meta.hot.dispose(() => {
    document && document.head.removeChild(styleEl);
  });

  const styleEl = document.createElement("style");
  const codeEl = document.createTextNode(code);
  styleEl.type = 'text/css';

  styleEl.appendChild(codeEl);
  document.head.appendChild(styleEl);
}

let json should have a value.

Confirm that it works in 3.3.2

let json = {"edit":"_edit_1fmvc_5","view":"_view_1fmvc_11"};
export default json;
@drwpow
Copy link
Collaborator

drwpow commented Apr 29, 2021

Thanks for filing. Yes behavior of CSS Modules did change in that commit as stated, but tests were added to test this exact behavior: https://github.com/snowpackjs/snowpack/blob/main/test/snowpack/cssModules/index.test.js#L148, and they’re currently passing. Are you able to provide a reproduction of this bug, or add a failing test in the Snowpack repo itself?

@drwpow drwpow self-assigned this Apr 29, 2021
@drwpow
Copy link
Collaborator

drwpow commented Apr 29, 2021

Actually this seems to be a duplicate of #3219

@drwpow drwpow closed this as completed Apr 29, 2021
@drwpow
Copy link
Collaborator

drwpow commented Apr 29, 2021

Bug should be fixed as of v3.3.6! 🎉 Thank you for filing.

@sminnee
Copy link
Author

sminnee commented May 2, 2021

Thanks! One thing I noticed today was that your experimental module combiner had a similar bug. I'll see if it's fixed in 3.3.6.

@sminnee
Copy link
Author

sminnee commented Aug 31, 2021

FYI I noted on #2998 that both ESbuild and Webpack bundling fail to handle CSS modules in 3.8.8.

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

No branches or pull requests

2 participants