Giter Site home page Giter Site logo

Comments (9)

Hyperkid123 avatar Hyperkid123 commented on July 21, 2024 2

I believe it is not necessary. I will fix the import so we should not need the workaround.

from frontend-components.

gkarat avatar gkarat commented on July 21, 2024

The bug is fairly easy to solve by using import RuleTable from '@redhat-cloud-services/rule-components/RuleTable/RuleTable'; instead. Do we need to update the docs instead?

from frontend-components.

akofink avatar akofink commented on July 21, 2024

@bastilian any thoughts on this one?

from frontend-components.

rvsia avatar rvsia commented on July 21, 2024

@gkarat This import works because ESM should use shared style files with CJS, however, our babel plugin for translating scss imports work only with ... imports. And the RuleTable component includes a scss re-export for some reason. So it is a bug in the component, not a documentation change. 😏 By using the import, you actually use a wrong module version of the component (CJS modules are not intended for modern browsers) and it could introduce some unexpected errors (as you mix CJS/ESM components in your app) and bigger bundle size (some components will be bundled in both CJS&ESM versions.)

I made a fix that adds export translator: #1228 However, I am not sure if we want it and if we should not just import the scss file instead of re-exporting, but I am not absolutely sure why this change https://github.com/RedHatInsights/frontend-components/pull/390/files was ever made and if really need it now. @karelhala cc @Hyperkid123

from frontend-components.

Hyperkid123 avatar Hyperkid123 commented on July 21, 2024

Well the thing is, the build component should not even resolve the .scss files but it should import only the .css files. 🤔 maybe we forgot to add the custom loader for the rule-component package? Gimme a sec to debug it.

from frontend-components.

Hyperkid123 avatar Hyperkid123 commented on July 21, 2024

@gkarat well I have found the issue. The RuleTable component is re-exporting the scss file as style. I am not but I am 100% sure it won't work with CSS modules which is the only thing I can imagine this would be useful.

This fixes the problem

diff --git a/packages/rule-components/src/RuleTable/RuleTable.js b/packages/rule-components/src/RuleTable/RuleTable.js
index 760e6e7f..003e24c0 100644
--- a/packages/rule-components/src/RuleTable/RuleTable.js
+++ b/packages/rule-components/src/RuleTable/RuleTable.js
@@ -11,7 +11,7 @@ import flatten from 'lodash/flatten';
 import debounce from 'lodash/debounce';
 import isEqual from 'lodash/isEqual';
 import { calculateMeta, calculateActiveFilters, createRows } from './helpers';
-export { default as style } from './index.scss';
+import './index.scss';
 
 class RuleTable extends Component {
     state = {

Before I apply it @akofink @gkarat is there any reason why the styles are re-exported?

from frontend-components.

rvsia avatar rvsia commented on July 21, 2024

@Hyperkid123 Check the PR I mentioned before: https://github.com/RedHatInsights/frontend-components/pull/390/files

from frontend-components.

Hyperkid123 avatar Hyperkid123 commented on July 21, 2024

Yeah, I saw it but it won't really help with the problem. The rule component is using CSS modules syntax but the component nor the library is set up to use/build CSS modules. If you want to consume the scss, you can import it into the project and go from there. SCSS files are available.

from frontend-components.

gkarat avatar gkarat commented on July 21, 2024

@Hyperkid123, @rvsia, thanks a lot for the clarification. I cannot comment anyhow on the necessity of re-export in this case.

from frontend-components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.