Skip to content
This repository has been archived by the owner on Aug 19, 2019. It is now read-only.

way to create a merged layer #5

Open
Guria opened this issue Mar 29, 2016 · 6 comments
Open

way to create a merged layer #5

Guria opened this issue Mar 29, 2016 · 6 comments

Comments

@Guria
Copy link
Contributor

Guria commented Mar 29, 2016

I wonder if it possible with current toolset to bundle a "merged" layer in dist. It would be great way to expose components to projects that not necessarily should know about underlie tech stack.

@deepsweet
Copy link
Member

what exactly do you mean by "merged" layer?

@Guria
Copy link
Contributor Author

Guria commented Mar 29, 2016

for given example it would like:

.
└── merged-layer/
    └── button/
        └── core-components.js   // export default class
        └── custom-components.js // import Button from './core-components'; export default class
        └── product-theme.js     // import Button from './custom-components'; export default class
        └── index.js             // export Button as default from './product-theme';
        └── index.css            // styles from theme-reset/button/styles.less and product-theme/button/styles.less

@Guria
Copy link
Contributor Author

Guria commented Mar 29, 2016

app

.
└── app/
    └── somewhere.js
import Button from 'merged-layer/button';
import 'merged-layer/button/index.css';

class SomeAppComponent extends React.Component {
    // ...
    return (
      //...
        <Button
          icon="never-gonna-give-you-up.png"
          onClick={doStuff}>
          {'Click me'}
        </Button>
      //...
    );
}

@deepsweet
Copy link
Member

I'm not quite sure that it's possible at all. I mean you can't prebuild your layer standalone because you don't know about other layers.

@mistadikay

@mistadikay
Copy link
Member

I think @Guria means prebuilding layer with resolved #-imports, so you can just require, for example, button — and it will be already prebuilded with all layers. Maybe it's possible to prebuild layer with a separate entry point for each component? But what about other dependencies, for example, if some component uses moment library — should it be bundled as well in this case?

@Guria
Copy link
Contributor Author

Guria commented Mar 30, 2016

@mistadikay yep, you are right. It should be some build tool which use layer array ([require('core-components'),require('theme-reset'),require('../custom-layer')]) as input and generates merged layer by resolving #-imports.

But what about other dependencies, for example, if some component uses moment library — should it be bundled as well in this case?

Of course not. Usual requires should left as is. Hmm. It means we should somehow merge dependencies from layers too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants