Skip to content

Special chars in CSS Class Names not Stripped from Exports (Causes Error) #45

Open
@kirvedx

Description

@kirvedx

Hello,

Thanks for taking over this project - I have a project template for React projects that depended on its predecessor and its nice to see someone picked it up.

Anyways, I've updated all deps (npx npm-check-updates -u && npm install) and after a bit of a configuration update The only error I'm getting that's preventing my compilation from completing successfully is:

ERROR in ./src/components/NodeKitCore/styles.scss (./node_modules/@teamsupercell/typings-for-css-modules-loader/src/index.js??ruleSet[1].rules[5].use[1]!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[3]!./src/components/NodeKitCore/styles.scss) 10:13
Module parse failed: Unexpected token (10:13)
File was processed with these loaders:
 * ./node_modules/@teamsupercell/typings-for-css-modules-loader/src/index.js
 * ./node_modules/css-loader/dist/cjs.js
 * ./node_modules/sass-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| export const standard = "_1FcZ2DoWKoMNzwvFsPE8n5";
| export const titleCapture = "_17mdMcJ5k7O5pYNkH6zUEi";
> export const +fullHeight = "_9aH9R-E-_bPyqa-v7dM67";
| export const +inverseColors = "_3Ur4Mt3ewSPWrwd_rncbkO";
| export const +flex = "_2AQUPgQwN28XGDEtM17H7A";
 @ ./src/components/NodeKitCore/styles.scss 2:12-306 9:17-24 13:15-29
 @ ./src/components/NodeKitCore/index.ts 12:15-39
 @ ./src/containers/App/App.tsx 18:22-61
 @ ./src/containers/App/index.ts 14:12-28
 @ ./src/app.tsx 15:14-41

I'd bother posting the source files, but I can just tell you that in a scss file somewhere along the way I have:

&.\+full-height {
        height: 100%;
    }

And according to the error, what's happening is that @teamsupercell/typings-for-css-modules-loader is attempting to create the export: export const +fullHeight = "_9a...";.

This is causing an error of course.

  • I'm leveraging the exportsLocalConvention: "camelCaseOnly" and namedExports: true options in css-loader.

Any idea on how I can get around this error? Could you ensure that named exports will generate only codeSafeNames ( String.replace() any special chars not allowed in variable names) in a subsequent release?

I might very well compile a pull request myself - but if this is a simple enough fix for you I'd imagine being the one to have been maintaining the plug-in you know exactly where to implement said check.

If I'm off about who's to blame for the issue please let me know . Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions