Open neoromantic opened 6 years ago
I suppose, I might be lacking some babel plugin, but all was working great on 1.5 :(
I've created demo repository with just clean Meteor 1.6, meteor-css-modules and Babel with env and react presets. Here it is: https://github.com/neoromantic/meteor-cssmodules-1.6
I can't get imported styles to work there either. What am I missing? Anyone?
While fighting with this, I've discovered a bug in Meteor 1.6 (rather unsettling) that prevented me from building my (1.5) app. So, please nevermind my plead for urgency and sorry for that also, nerves :)
But problem stands, can't get css-modules to work on 1.6.
I have the same problem. I'm curious if this have to do with the fact that node 8 supports import and export natively? And meteor removed Reify that made it possible before.
I ran into the same thing - it seems like a problem with the default export.
Until it gets fixed, I found a quick fix (depending how many places you are importing styles) is to import styles
by it's name instead of default, e.g.:
import { styles } from './styles.m.css';
https://github.com/nathantreid/meteor-css-modules/issues/106#issuecomment-341252464 works for me, and using sass/scss. 💃 in case you have multiple imports just:
import { styles } from './styles.scss';
import { styles as table } from './table.scss';
Wow, cool. But is it meteor-css-modules bug or something regarding node8/babel?
Seems like no brainer to replace it all in my code, but feels wrong to do that not knowing why it is so.
In any case, thanks a lot, guys.
However, react-toolbox doesn't work :(
Do you have any idea on how to work around that one? I use react-toolbox installed with npm.
It looks like this is a change in 1.6. I've chimed in on a Meteor issue report, so we'll wait to see what the feedback is. In the meantime, you can also import the default styles by appending .js
to your file path, e.g.
import styles from './somemodule.scss.js'
. Unfortunately I don't think npm packages will work until this is resolved since the default exports won't load properly for them.
FYI, I get this same problem using css-modules with typescript (replaced babel with barbatus/typescript). I needed to follow comments above as well and import { styles } from ./my-css.css
as opposed to import * as styles from ./my-css.css
as I typically would in typescript.
@nathantreid so, did anyone managed to get react-toolbox working well with meteor 1.6 and css-modules 3.0.0?
I couldn't. Is there a point in trying?
Meteor 1.6.1 included the imports fix, so I've published v3.0.1 to support it (and fix a couple of other bugs). @neoromantic react-toolbox now works in my tests!
Hi, thanks for the nice work. I tried to install v3.0.1 but there seems to be a conflict : Conflict: Constraint ecmascript@0.10.0 is not satisfied by ecmascript 0.9.0. ecmascript@0.10.0 <- nathantreid:css-modules 3.0.1
Here is the list of installed packages:
accounts-google 1.3.1 Login service for Google accounts
accounts-password 1.5.0 Password support for accounts
accounts-ui 1.2.0* Simple templates to add login widgets to an app
blaze-html-templates 1.1.2 Compile HTML templates into reactive UI with Meteor Blaze
check 1.2.5* Check whether a value matches a pattern
cottz:publish-relations 2.0.8 Edit your documents before sending without too much stress
ecmascript 0.9.0* Compiler plugin that supports ES2015+ in all .js files
email 1.2.3 Send email messages
es5-shim 4.6.15* Shims and polyfills to improve ECMAScript 5 support
google-config-ui 1.0.0 Blaze configuration templates for Google OAuth.
jagi:astronomy 2.5.2 Model layer for Meteor
jagi:astronomy-timestamp-behavior 2.0.0 Timestamp behavior for Meteor Astronomy
meteor-base 1.2.0* Packages that every Meteor app needs
mobile-experience 1.0.5 Packages for a great mobile user experience
mongo 1.3.1* Adaptor for using MongoDB and Minimongo over DDP
msavin:mongol 4.0.1 In-App MongoDB Editor.. now with improved third party package compatibility.
nathantreid:css-modules 3.0.0* CSS modules implementation. CSS for components!
react-meteor-data 0.2.15 React higher-order component for reactively tracking Meteor data
reactive-var 1.0.11 Reactive variable
service-configuration 1.0.11 Manage the configuration for third-party services
shell-server 0.3.1 Server-side component of the `meteor shell` command.
standard-minifier-css 1.3.5* Standard css minifier used with Meteor apps by default.
standard-minifier-js 2.2.3* Standard javascript minifiers used with Meteor apps by default.
tracker 1.1.3 Dependency tracker to allow reactive callbacks
I started with a fresh new meteor project, but can't make it work...
@thoomasbro Based on your package versions, it looks like you're running Meteor 1.6; for v3.0.1, you'll need to be on Meteor 1.6.1. Meteor 1.6.0.1 is still the recommended release (or it was yesterday, anyway) so to create a new project with Meteor 1.6.1, add the --release
flag to your meteor command:
meteor create --release 1.6.1 my-project-name
You can use the same flag to update an existing project.
thanks, seems to work like a charm!
I updated to meteor@1.6.1 and nathantreid:css-modules@3.0.1. The import works now and the components are styled for the normal js style import of import styles from ./my-css.css
, but in the case of using typescript, the import needs to be in the format import * as styles from ./my-css.css
to avoid a typescript error. Css imported in the typescript way still doesn't get processed and the components remain unstyled.
@warmbowski I just ran a test with barbatus:typescript, and importing is working. You'll need to use the format import styles from ./my-css.css
, the import *
format will not work; more precisely, if you use import * as styles
it'll work, but styles
will be a subproperty (styles.styles
).
To remove the cannot find module
error, I added a generic typing for .css
files:
declare module '*.css';
Sample project here: https://github.com/nathantreid/css-modules-barbatus-typescript-sample
Hi, If there is always a problem for some on meteor 1.6.1.1 and meteor-css-modules 3.1.3 to properly display react-toolbox components, I have no problem using the fourseven:scss
meteor package instead of npm node-sass
in a react-toolbox project. It is the recommended sass package for meteor
I'm importing CSS in MyComponent.jsx
with
import styles from './MyComponent.css'
Then I'm importing react-toolbox themes customizations like that
import theme from './_theme.css'
@xlinbsd Can you elaborate on the issue you are experiencing (expected vs actual behavior) and provide a reproduction repo? Thanks!
@nathantreid, I have no issue to demonstrate. I figured out a possible solution to the @neoromantic issue with react-toolbox component displayed css-naked.
I've been using this package for awhile now, along with meteor 1.4, 1.5 and now I'm trying to get it working with 1.6. Also, I use react-toolbox.
Currently, I just get unstyled components, as if no
import styles from 'file.css'
were working. No errors, I even see 'processing files with nathantreid:meteor-css-modules' line when run devserver. But no css code gets to client.I suppose my configuration is a bit wrong, could anyone point me to an error?
Here's my setup:
.meteor/packages
package.json
.babelrc:
I use styles like that:
@nathantreid if you could help soon, it would get me out of deep shithole, since I just can't release my project after Meteor 1.6 came around (old version doesn't builds in my CI process, i have to upgrade to 1.6 as it seems)