@parcel/utils 2.3.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/utils",
3
- "version": "2.3.2",
3
+ "version": "2.4.0",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,11 +33,11 @@
33
33
  }
34
34
  },
35
35
  "dependencies": {
36
- "@parcel/codeframe": "2.3.2",
37
- "@parcel/diagnostic": "2.3.2",
38
- "@parcel/hash": "2.3.2",
39
- "@parcel/logger": "2.3.2",
40
- "@parcel/markdown-ansi": "2.3.2",
36
+ "@parcel/codeframe": "2.4.0",
37
+ "@parcel/diagnostic": "2.4.0",
38
+ "@parcel/hash": "2.4.0",
39
+ "@parcel/logger": "2.4.0",
40
+ "@parcel/markdown-ansi": "2.4.0",
41
41
  "@parcel/source-map": "^2.0.0",
42
42
  "chalk": "^4.1.0"
43
43
  },
@@ -64,5 +64,5 @@
64
64
  "./src/http-server.js": false,
65
65
  "./src/openInBrowser.js": false
66
66
  },
67
- "gitHead": "47379bf8fabeb2cfe03ade8802d942388b153e5b"
67
+ "gitHead": "b1bbfdab2e902d33c0b6ff75bfba2d22283a8de6"
68
68
  }
@@ -33,6 +33,7 @@ export function replaceURLReferences({
33
33
  bundleGraph,
34
34
  contents,
35
35
  map,
36
+ getReplacement = s => s,
36
37
  relative = true,
37
38
  }: {|
38
39
  bundle: NamedBundle,
@@ -40,6 +41,7 @@ export function replaceURLReferences({
40
41
  contents: string,
41
42
  relative?: boolean,
42
43
  map?: ?SourceMap,
44
+ getReplacement?: string => string,
43
45
  |}): {|+contents: string, +map: ?SourceMap|} {
44
46
  let replacements = new Map();
45
47
  let urlDependencies = [];
@@ -61,7 +63,7 @@ export function replaceURLReferences({
61
63
  if (resolved == null) {
62
64
  replacements.set(placeholder, {
63
65
  from: placeholder,
64
- to: dependency.specifier,
66
+ to: getReplacement(dependency.specifier),
65
67
  });
66
68
  continue;
67
69
  }
@@ -79,6 +81,7 @@ export function replaceURLReferences({
79
81
  fromBundle: bundle,
80
82
  toBundle: resolved,
81
83
  relative,
84
+ getReplacement,
82
85
  }),
83
86
  );
84
87
  }
@@ -156,11 +159,13 @@ export function getURLReplacement({
156
159
  fromBundle,
157
160
  toBundle,
158
161
  relative,
162
+ getReplacement,
159
163
  }: {|
160
164
  dependency: Dependency,
161
165
  fromBundle: NamedBundle,
162
166
  toBundle: NamedBundle,
163
167
  relative: boolean,
168
+ getReplacement?: string => string,
164
169
  |}): {|from: string, to: string|} {
165
170
  let to;
166
171
 
@@ -191,9 +196,10 @@ export function getURLReplacement({
191
196
 
192
197
  let placeholder = dependency.meta?.placeholder ?? dependency.id;
193
198
  invariant(typeof placeholder === 'string');
199
+
194
200
  return {
195
201
  from: placeholder,
196
- to,
202
+ to: getReplacement ? getReplacement(to) : to,
197
203
  };
198
204
  }
199
205