andywer/webpack-blocks

1.0.0 migration: Block returns blocks?

boxfoot opened this issue · 3 comments

I'm trying my hand at updating a third-party webpack block to the new api. The block I'm trying to convert is https://github.com/diegohaz/webpack-blocks-happypack which may be a funny place to start, given how complex a block it is.

I'm having trouble figuring out how to update the main webpack-block itself.

The existing block (API 0.4.x) has a format of:

const happypack = (originalBlocks, options) => {
     const newBlocks = doSomeManipulations(originalBlocks);
     return group(newBlocks);
}

I'm not sure how to convert this to the new form (API 1.0.0):

const happypack = (originalBlocks, options) => {
    return (context, utils) => prevConfig => {
             const newBlocks = doSomeManipulations(originalBlocks);
             // how do I compile/integrate these new blocks into prevConfig?
             const newConfig = ???
             return newConfig;
     };
};

In the spirit of "inspiration comes after you ask for help," I think I see what I was doing wrong. Closing for now, will reopen with a clarified question if necessary.

I think I mostly figured it out!
@andywer it would be great if you could take a look at my PR over at webpack-blocks-happypack. I know you're not maintainer for that package, but from issue history it looks like you helped design the approach. I'd also appreciate your take on some of the differences in the jest snapshots -- whether those are significant and/or how to make adjustments for the webpack-blocks API. Thanks!

@boxfoot Sure, I will have a look 😉