Skip to content

Commit

Permalink
Handle undefined in removeQueryParams
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcompiles authored and nr-tw committed Nov 14, 2022
1 parent 8c07764 commit e88eca9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/plugins/babel/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ function addDotSlashPrefix(path: string): string {
return hasRelativePrefix(path) ? path : `./${path}`;
}

function removeQueryParams(input: string) {
function removeQueryParams(input: string | undefined) {
// When resolving a package with `exports` in the package.json, `enhanced-resolve` will fail
// match if the import contains a query string. Query strings could be used to pass import
// meta data in some cases (e.g. Parcel with support for "magic comments")
if (!input) {
return input;
}

const qsPos = input.indexOf('?');

if (qsPos !== -1) {
Expand Down
6 changes: 5 additions & 1 deletion packages/plugins/parcel-reporter-manifest/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ const getAssetId = (basePath: string, assetPath: string) => {
return assetId;
};

const removeQueryParams = (input: string) => {
const removeQueryParams = (input: string | undefined) => {
// When resolving a package with `exports` in the package.json, `enhanced-resolve` will fail
// match if the import contains a query string. Query strings could be used to pass import
// meta data in some cases (e.g. Parcel with support for "magic comments")
if (!input) {
return input;
}

const qsPos = input.indexOf('?');

if (qsPos !== -1) {
Expand Down
6 changes: 5 additions & 1 deletion packages/plugins/parcel-transformer/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ export const findUsages = (code: string, importSpecifiers: Set<string>) => {
return usages;
};

const removeQueryParams = (input: string) => {
const removeQueryParams = (input: string | undefined) => {
// When resolving a package with `exports` in the package.json, `enhanced-resolve` will fail
// match if the import contains a query string. Query strings could be used to pass import
// meta data in some cases (e.g. Parcel with support for "magic comments")
if (!input) {
return input;
}

const qsPos = input.indexOf('?');

if (qsPos !== -1) {
Expand Down
6 changes: 5 additions & 1 deletion packages/plugins/webpack/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,14 @@ export const buildManifest = (
);
};

export const removeQueryParams = (input: string) => {
export const removeQueryParams = (input: string | undefined) => {
// When resolving a package with `exports` in the package.json, `enhanced-resolve` will fail
// match if the import contains a query string. Query strings could be used to pass import
// meta data in some cases (e.g. Parcel with support for "magic comments")
if (!input) {
return input;
}

const qsPos = input.indexOf('?');

if (qsPos !== -1) {
Expand Down

0 comments on commit e88eca9

Please sign in to comment.