Code Monkey home page Code Monkey logo

Comments (4)

tleunen avatar tleunen commented on June 27, 2024

Looks like the option normalizeFilenames can resolve this by removing the auto generated name. But when I use the option, only the files having that generated id get reported.

All other files get lost in the process and are reported with an empty string instead

PASS  : 184KB < 250KB (brotli)

from bundlewatch.

tleunen avatar tleunen commented on June 27, 2024

The problem seems to be this line

.split(normalizeFilenames)

As if there's no group being found, split returns the whole path

from bundlewatch.

tleunen avatar tleunen commented on June 27, 2024

Making my group optional in my regex kind of fixes the issue... But it makes the split function returning an undefined value and we do a replace on an undefined (my files don't have undefined so it's alright I guess).

Might be worth it to replace the split with a match instead and really check the results.

Something along these lines maybe

let normalizedFilePath = filePath;
if (normalizeFilenames) {
  const match = filePath.match(normalizeFilenames);
  if (match != null) {
    const [, matches] = match;
    normalizedFilePath = matches.reduce((acc, m) => acc.replace(m, ''), filePath);
  }
}

from bundlewatch.

charpeni avatar charpeni commented on June 27, 2024

Thanks for reporting this. This is definitely annoying when all your files aren't matching with normalizeFilenames, I encountered this recently and I had to do like you said, use an optional group.

Would you like to send a pull request with tests? I will be happy to review it.

from bundlewatch.

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.