peerigon / extract-loader

webpack loader to extract HTML and CSS from the bundle
The Unlicense
317 stars 74 forks source link

v5.2.0 breaks parts of code loaded with ref-loader #85

Open marapper opened 4 years ago

marapper commented 4 years ago

We use extract-loader to compose template files like this:

// index.js
import template from '!file-loader!extract-loader!ref-loader!./template.soy';

// template.soy 
@ref(!ref-loader!./Part1.soy)
@ref(!ref-loader!./Part2.soy)

// Part1.soy
{template .Part1}
    {foreach $key in keys($ij.pageItem.preferences)}
        {if matches($key, '^visible_.*$')}
        {/if}
    {/foreach}
{/template}

// Part2.soy
{template .Part2}
{/template}

After upgrade extract-loader to v5.2.0 whole code part after $ is not included in result file. Downgrade extract-loader to v5.0.1 only works fine.

e.g. produce

// template.soy
{template .BackbaseModel}
    {foreach $key in keys($ij.pageItem.preferences)}
        {if matches($key, '^visible_.*$

{template .Part2}
{/template}

I suppose it's regex-relative thing. Probably somewhat connected with #57 and #54 ()

marapper commented 2 years ago

83 connected

src/extractLoader.js:175

should be


return content.replace(pattern, () => dependencyContent);

because replace callbacks ignore special sequences like $'