@parcel/utils 2.3.2 → 2.5.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.5.0",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,16 +33,15 @@
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.5.0",
37
+ "@parcel/diagnostic": "2.5.0",
38
+ "@parcel/hash": "2.5.0",
39
+ "@parcel/logger": "2.5.0",
40
+ "@parcel/markdown-ansi": "2.5.0",
41
41
  "@parcel/source-map": "^2.0.0",
42
42
  "chalk": "^4.1.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@babel/plugin-transform-flow-strip-types": "^7.2.0",
46
45
  "@iarna/toml": "^2.2.0",
47
46
  "ansi-html-community": "0.0.8",
48
47
  "clone": "^2.1.1",
@@ -64,5 +63,5 @@
64
63
  "./src/http-server.js": false,
65
64
  "./src/openInBrowser.js": false
66
65
  },
67
- "gitHead": "47379bf8fabeb2cfe03ade8802d942388b153e5b"
66
+ "gitHead": "5cfb846d742eb86b1232e531be6e0e513551d838"
68
67
  }
@@ -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
 
package/src/schema.js CHANGED
@@ -4,7 +4,7 @@ import ThrowableDiagnostic, {
4
4
  escapeMarkdown,
5
5
  encodeJSONKeyComponent,
6
6
  } from '@parcel/diagnostic';
7
- import type {Mapping} from 'json-source-map';
7
+ import type {Mapping} from '@mischnic/json-sourcemap';
8
8
  import nullthrows from 'nullthrows';
9
9
  // flowlint-next-line untyped-import:off
10
10
  import levenshtein from 'fastest-levenshtein';
@@ -406,7 +406,7 @@ validateSchema.diagnostic = function (
406
406
  !data
407
407
  ) {
408
408
  throw new Error(
409
- 'At least one of data.source and data.source must be defined!',
409
+ 'At least one of data.source and data.data must be defined!',
410
410
  );
411
411
  }
412
412
  let object = data.map