Daniel Roe (author of Nuxt) reports that a new npm package will now be used for route analysis:
https://github.com/nuxt/nuxt/releases/tag/v4.4.0
Performance improvements are always good. But what's happening under the hood? Looking at the GitHub changes:
We've migrated Nuxt's file-system route generation to unrouting (#34316), which uses a trie data structure for constructing routes. The cold start is roughly the same (~8ms vs ~6ms for large apps), but dev server changes are up to 28x faster when you're not adding/removing pages, and ~15% faster even when you are.
https://github.com/nuxt/nuxt/releases/tag/v4.4.0
Performance improvements are always good. But what's happening under the hood? Looking at the GitHub changes:
In reality, 3 packages were added - which means yet another pile of files in node_modules. Along with unrouting, picomatch and @types/picomatch will also be installed. All these packages bring along a lot of semi-junk files:
unrouting was written by Daniel Roe himself. This package already has 2 dependencies: escape-string-regexp and ufo. Let's take a look at escape-string-regexp. On npm, this package was last updated in 2021! It exports a single helper function:
And this situation exists across thousands of packages in thousands of projects. Millions of files are copied just for the sake of one function. Every time during CI/CD or local development around the world, semi-junk files like README.md, LICENSE, and others get copied, directories are created, and so on.
Name Type Size lib/ folder 59.6 kB LICENSE text/plain 1.09 kB README.md text/markdown 28.3 kB index.js application/javascript 479 B package.json application/json 1.9 kB posix.js application/javascript 60 BIt may seem insignificant, but every npm package drags this stuff along with it.
unrouting was written by Daniel Roe himself. This package already has 2 dependencies: escape-string-regexp and ufo. Let's take a look at escape-string-regexp. On npm, this package was last updated in 2021! It exports a single helper function:
export default function escapeStringRegexp(string) {
if (typeof string !== 'string') {
throw new TypeError('Expected a string');
}
// Escape characters with special meaning either inside or outside character sets.
// Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
return string
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
.replace(/-/g, '\\x2d');
}
Why not just copy this function directly into the project instead of pulling in an entire dependency?And this situation exists across thousands of packages in thousands of projects. Millions of files are copied just for the sake of one function. Every time during CI/CD or local development around the world, semi-junk files like README.md, LICENSE, and others get copied, directories are created, and so on.
