Skip to content

Commit

Permalink
Make Webpack loader detection regex dramatically faster (#7226)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Nov 2, 2021
1 parent 012380f commit 1d32c80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/core/integration-tests/test/resolver.js
Expand Up @@ -382,4 +382,20 @@ describe('resolver', function () {
let output = await run(b);
assert.strictEqual(output.default, 2);
});

it('should support very long dependency specifiers', async function () {
this.timeout(8000);

let inputDir = path.join(__dirname, 'input');

await outputFS.mkdirp(inputDir);
await outputFS.writeFile(
path.join(inputDir, 'index.html'),
`<img src="data:image/jpeg;base64,/9j/${'A'.repeat(200000)}">`,
);

await bundle(path.join(inputDir, 'index.html'), {
inputFS: overlayFS,
});
});
});
2 changes: 1 addition & 1 deletion packages/resolvers/default/src/DefaultResolver.js
Expand Up @@ -5,7 +5,7 @@ import NodeResolver from '@parcel/node-resolver-core';

// Throw user friendly errors on special webpack loader syntax
// ex. `imports-loader?$=jquery!./example.js`
const WEBPACK_IMPORT_REGEX = /\S+-loader\S*!\S+/g;
const WEBPACK_IMPORT_REGEX = /^\w+-loader(?:\?\S*)?!/;

export default (new Resolver({
resolve({dependency, options, specifier}) {
Expand Down

0 comments on commit 1d32c80

Please sign in to comment.