@parcel/utils 2.0.0-nightly.150 → 2.0.0-nightly.1500

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.
Files changed (105) hide show
  1. package/.eslintrc.js +6 -6
  2. package/lib/index.js +37626 -318
  3. package/lib/index.js.map +1 -0
  4. package/package.json +47 -20
  5. package/src/DefaultMap.js +1 -1
  6. package/src/PromiseQueue.js +16 -12
  7. package/src/alternatives.js +145 -0
  8. package/src/ansi-html.js +2 -2
  9. package/src/blob.js +2 -1
  10. package/src/bundle-url.js +1 -1
  11. package/src/collection.js +35 -15
  12. package/src/config.js +132 -45
  13. package/src/countLines.js +5 -2
  14. package/src/debounce.js +1 -1
  15. package/src/dependency-location.js +11 -6
  16. package/src/generateBuildMetrics.js +158 -0
  17. package/src/generateCertificate.js +1 -1
  18. package/src/getCertificate.js +1 -1
  19. package/src/getExisting.js +1 -4
  20. package/src/getModuleParts.js +23 -0
  21. package/src/getRootDir.js +1 -2
  22. package/src/glob.js +51 -10
  23. package/src/hash.js +49 -0
  24. package/src/http-server.js +29 -19
  25. package/src/index.js +68 -22
  26. package/src/is-url.js +1 -1
  27. package/src/isDirectoryInside.js +11 -0
  28. package/src/openInBrowser.js +64 -0
  29. package/src/path.js +38 -6
  30. package/src/prettyDiagnostic.js +102 -30
  31. package/src/progress-message.js +22 -0
  32. package/src/relativeBundlePath.js +8 -13
  33. package/src/replaceBundleReferences.js +85 -41
  34. package/src/schema.js +100 -44
  35. package/src/shared-buffer.js +23 -0
  36. package/src/sourcemap.js +138 -0
  37. package/src/stream.js +31 -1
  38. package/src/urlJoin.js +3 -1
  39. package/test/DefaultMap.test.js +7 -4
  40. package/test/collection.test.js +13 -1
  41. package/test/config.test.js +98 -0
  42. package/test/input/config/.testrc +3 -0
  43. package/test/input/config/config.cjs +3 -0
  44. package/test/input/config/config.js +3 -0
  45. package/test/input/config/config.json +3 -0
  46. package/test/input/config/empty.json +0 -0
  47. package/test/input/config/empty.toml +0 -0
  48. package/test/input/sourcemap/referenced-min.js +2 -0
  49. package/test/input/sourcemap/referenced-min.js.map +6 -0
  50. package/test/input/sourcemap/source-root.js +2 -0
  51. package/test/input/sourcemap/source-root.js.map +7 -0
  52. package/test/replaceBundleReferences.test.js +268 -0
  53. package/test/sourcemap.test.js +207 -0
  54. package/test/throttle.test.js +1 -2
  55. package/test/urlJoin.test.js +37 -0
  56. package/lib/DefaultMap.js +0 -64
  57. package/lib/Deferred.js +0 -26
  58. package/lib/PromiseQueue.js +0 -133
  59. package/lib/TapStream.js +0 -41
  60. package/lib/ansi-html.js +0 -16
  61. package/lib/blob.js +0 -31
  62. package/lib/bundle-url.js +0 -43
  63. package/lib/collection.js +0 -62
  64. package/lib/config.js +0 -88
  65. package/lib/countLines.js +0 -18
  66. package/lib/debounce.js +0 -20
  67. package/lib/dependency-location.js +0 -21
  68. package/lib/escape-html.js +0 -24
  69. package/lib/escape-markdown.js +0 -15
  70. package/lib/generateBundleReport.js +0 -38
  71. package/lib/generateCertificate.js +0 -124
  72. package/lib/getCertificate.js +0 -19
  73. package/lib/getExisting.js +0 -23
  74. package/lib/getRootDir.js +0 -55
  75. package/lib/glob.js +0 -76
  76. package/lib/http-server.js +0 -64
  77. package/lib/is-url.js +0 -17
  78. package/lib/loadSourceMapUrl.js +0 -33
  79. package/lib/md5.js +0 -35
  80. package/lib/objectHash.js +0 -26
  81. package/lib/parseCSSImport.js +0 -16
  82. package/lib/path.js +0 -22
  83. package/lib/prettifyTime.js +0 -10
  84. package/lib/prettyDiagnostic.js +0 -57
  85. package/lib/promisify.js +0 -13
  86. package/lib/relativeBundlePath.js +0 -24
  87. package/lib/relativeUrl.js +0 -16
  88. package/lib/replaceBundleReferences.js +0 -151
  89. package/lib/resolve.js +0 -93
  90. package/lib/schema.js +0 -320
  91. package/lib/serializeObject.js +0 -28
  92. package/lib/stream.js +0 -51
  93. package/lib/throttle.js +0 -16
  94. package/lib/urlJoin.js +0 -27
  95. package/src/.babelrc +0 -3
  96. package/src/escape-markdown.js +0 -10
  97. package/src/generateBundleReport.js +0 -51
  98. package/src/loadSourceMapUrl.js +0 -33
  99. package/src/md5.js +0 -44
  100. package/src/promisify.js +0 -13
  101. package/src/resolve.js +0 -135
  102. package/src/serializeObject.js +0 -22
  103. package/test/escapeMarkdown.test.js +0 -29
  104. package/test/input/sourcemap/referenced.js +0 -7
  105. package/test/loadSourceMapUrl.test.js +0 -37
@@ -0,0 +1,268 @@
1
+ // @flow strict-local
2
+
3
+ import type {NamedBundle, Dependency} from '@parcel/types';
4
+
5
+ import assert from 'assert';
6
+ import {getURLReplacement} from '../src/replaceBundleReferences';
7
+
8
+ describe('replace bundle references', () => {
9
+ it('Query params and named pipeline, relative', () => {
10
+ // $FlowFixMe
11
+ let fromBundle: NamedBundle = {
12
+ filePath: '/user/dist/reformat.html',
13
+ name: 'reformat.html',
14
+ // $FlowFixMe
15
+ target: {
16
+ distDir: '/user/dist',
17
+ publicUrl: '/',
18
+ },
19
+ };
20
+
21
+ // $FlowFixMe
22
+ let toBundle: NamedBundle = {
23
+ filePath:
24
+ '/user/dist/image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
25
+ name: 'image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
26
+ // $FlowFixMe
27
+ target: {
28
+ distDir: '/user/dist',
29
+ publicUrl: '/',
30
+ },
31
+ };
32
+
33
+ // $FlowFixMe
34
+ let dependency: Dependency = {
35
+ id: '074b36596e3147e900a8ad17ceb5c90b',
36
+ specifier: 'url:./image.jpg?as=webp',
37
+ specifierType: 'esm',
38
+ };
39
+
40
+ let result = getURLReplacement({
41
+ dependency,
42
+ fromBundle,
43
+ toBundle,
44
+ relative: true,
45
+ });
46
+
47
+ assert.equal(
48
+ result.to,
49
+ 'image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
50
+ );
51
+ assert.equal(result.from, '074b36596e3147e900a8ad17ceb5c90b');
52
+ });
53
+
54
+ it('Query params and named pipeline, absolute', () => {
55
+ // $FlowFixMe
56
+ let fromBundle: NamedBundle = {
57
+ filePath: '/user/dist/reformat.html',
58
+ name: 'reformat.html',
59
+ // $FlowFixMe
60
+ target: {
61
+ distDir: '/user/dist',
62
+ publicUrl: '/',
63
+ },
64
+ };
65
+
66
+ // $FlowFixMe
67
+ let toBundle: NamedBundle = {
68
+ filePath:
69
+ '/user/dist/image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
70
+ name: 'image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
71
+ // $FlowFixMe
72
+ target: {
73
+ distDir: '/user/dist',
74
+ publicUrl: '/',
75
+ },
76
+ };
77
+
78
+ // $FlowFixMe
79
+ let dependency: Dependency = {
80
+ id: '074b36596e3147e900a8ad17ceb5c90b',
81
+ specifier: 'url:./image.jpg?as=webp',
82
+ specifierType: 'esm',
83
+ };
84
+
85
+ let result = getURLReplacement({
86
+ dependency,
87
+ fromBundle,
88
+ toBundle,
89
+ relative: false,
90
+ });
91
+
92
+ assert.equal(
93
+ result.to,
94
+ '/image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
95
+ );
96
+ assert.equal(result.from, '074b36596e3147e900a8ad17ceb5c90b');
97
+ });
98
+
99
+ it('Custom Public URL', () => {
100
+ // $FlowFixMe
101
+ let fromBundle: NamedBundle = {
102
+ filePath: '/user/dist/reformat.html',
103
+ name: 'reformat.html',
104
+ // $FlowFixMe
105
+ target: {
106
+ distDir: '/user/dist',
107
+ publicUrl: 'https://test.com/static',
108
+ },
109
+ };
110
+
111
+ // $FlowFixMe
112
+ let toBundle: NamedBundle = {
113
+ filePath:
114
+ '/user/dist/image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
115
+ name: 'image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
116
+ // $FlowFixMe
117
+ target: {
118
+ distDir: '/user/dist',
119
+ publicUrl: 'https://test.com/static',
120
+ },
121
+ };
122
+
123
+ // $FlowFixMe
124
+ let dependency: Dependency = {
125
+ id: '074b36596e314797845a8ad17ceb5c9b',
126
+ specifier: './image.jpg',
127
+ specifierType: 'esm',
128
+ };
129
+
130
+ let result = getURLReplacement({
131
+ dependency,
132
+ fromBundle,
133
+ toBundle,
134
+ relative: false,
135
+ });
136
+
137
+ assert.equal(
138
+ result.to,
139
+ 'https://test.com/static/image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
140
+ );
141
+ assert.equal(result.from, '074b36596e314797845a8ad17ceb5c9b');
142
+ });
143
+
144
+ it('Relative with folders in between', () => {
145
+ // $FlowFixMe
146
+ let fromBundle: NamedBundle = {
147
+ filePath: '/user/dist/reformat.html',
148
+ name: 'reformat.html',
149
+ // $FlowFixMe
150
+ target: {
151
+ distDir: '/user/dist',
152
+ publicUrl: 'https://test.com/static',
153
+ },
154
+ };
155
+
156
+ // $FlowFixMe
157
+ let toBundle: NamedBundle = {
158
+ filePath:
159
+ '/user/dist/assets/image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
160
+ name: 'image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
161
+ // $FlowFixMe
162
+ target: {
163
+ distDir: '/user/dist/assets',
164
+ publicUrl: 'https://test.com/static',
165
+ },
166
+ };
167
+
168
+ // $FlowFixMe
169
+ let dependency: Dependency = {
170
+ id: '074b36596e3147e900a8ad17ceb5c90b',
171
+ specifier: 'url:./image.jpg?as=webp',
172
+ specifierType: 'esm',
173
+ };
174
+
175
+ let result = getURLReplacement({
176
+ dependency,
177
+ fromBundle,
178
+ toBundle,
179
+ relative: true,
180
+ });
181
+
182
+ assert.equal(
183
+ result.to,
184
+ 'assets/image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
185
+ );
186
+ assert.equal(result.from, '074b36596e3147e900a8ad17ceb5c90b');
187
+ });
188
+
189
+ it('should work with bundle names with colons, relative', () => {
190
+ // $FlowFixMe
191
+ let fromBundle: NamedBundle = {
192
+ filePath: '/user/dist/reformat.html',
193
+ name: 'reformat.html',
194
+ // $FlowFixMe
195
+ target: {
196
+ distDir: '/user/dist',
197
+ publicUrl: '/',
198
+ },
199
+ };
200
+
201
+ // $FlowFixMe
202
+ let toBundle: NamedBundle = {
203
+ filePath: '/user/dist/a:b:c.html',
204
+ name: 'a:b:c.html',
205
+ // $FlowFixMe
206
+ target: {
207
+ distDir: '/user/dist',
208
+ publicUrl: '/',
209
+ },
210
+ };
211
+
212
+ // $FlowFixMe
213
+ let dependency: Dependency = {
214
+ id: '074b36596e3147e900a8ad17ceb5c90b',
215
+ specifier: './a:b:c.html',
216
+ specifierType: 'esm',
217
+ };
218
+
219
+ let result = getURLReplacement({
220
+ dependency,
221
+ fromBundle,
222
+ toBundle,
223
+ relative: true,
224
+ });
225
+
226
+ assert.equal(result.to, './a:b:c.html');
227
+ });
228
+
229
+ it('should work with bundle names with colons, absolute', () => {
230
+ // $FlowFixMe
231
+ let fromBundle: NamedBundle = {
232
+ filePath: '/user/dist/reformat.html',
233
+ name: 'reformat.html',
234
+ // $FlowFixMe
235
+ target: {
236
+ distDir: '/user/dist',
237
+ publicUrl: '/',
238
+ },
239
+ };
240
+
241
+ // $FlowFixMe
242
+ let toBundle: NamedBundle = {
243
+ filePath: '/user/dist/a:b:c.html',
244
+ name: 'a:b:c.html',
245
+ // $FlowFixMe
246
+ target: {
247
+ distDir: '/user/dist',
248
+ publicUrl: '/',
249
+ },
250
+ };
251
+
252
+ // $FlowFixMe
253
+ let dependency: Dependency = {
254
+ id: '074b36596e3147e900a8ad17ceb5c90b',
255
+ specifier: './a:b:c.html',
256
+ specifierType: 'esm',
257
+ };
258
+
259
+ let result = getURLReplacement({
260
+ dependency,
261
+ fromBundle,
262
+ toBundle,
263
+ relative: false,
264
+ });
265
+
266
+ assert.equal(result.to, '/a:b:c.html');
267
+ });
268
+ });
@@ -0,0 +1,207 @@
1
+ import assert from 'assert';
2
+ import {
3
+ matchSourceMappingURL,
4
+ loadSourceMapUrl,
5
+ loadSourceMap,
6
+ } from '../src/sourcemap';
7
+ import {NodeFS} from '@parcel/fs';
8
+ import path from 'path';
9
+
10
+ const fs = new NodeFS();
11
+
12
+ describe('loadSourceMap', () => {
13
+ it('should not match sourceMappingURL when not at the end of the bundle', () => {
14
+ // Code example taken from livescript.js (issue #2408 in parcel-bundler)
15
+ // This snippet lead to JSAsset.js being mislead and incorrectly trying to
16
+ // load (due to false-positive match) sourcemap before fix was introduced
17
+ let code = fs.readFileSync(
18
+ path.join(__dirname, './input/sourcemap/no-sourcemap.js'),
19
+ 'utf-8',
20
+ );
21
+
22
+ assert(!matchSourceMappingURL(code));
23
+ });
24
+
25
+ it('should match referenced-min sourceMappingURL when correctly inserted at end of the bundle', () => {
26
+ let code = fs.readFileSync(
27
+ path.join(__dirname, './input/sourcemap/referenced-min.js'),
28
+ 'utf-8',
29
+ );
30
+
31
+ assert(!!matchSourceMappingURL(code));
32
+ });
33
+
34
+ it('should match inline sourceMappingURL when correctly inserted at end of the bundle', () => {
35
+ // inline source map taken from https://github.com/thlorenz/inline-source-map
36
+ let code = fs.readFileSync(
37
+ path.join(__dirname, './input/sourcemap/inline.js'),
38
+ 'utf-8',
39
+ );
40
+
41
+ assert(!!matchSourceMappingURL(code));
42
+ });
43
+
44
+ it('Should be able to load sourcemap data from a url reference', async () => {
45
+ let filename = path.join(__dirname, './input/sourcemap/referenced-min.js');
46
+ let contents = fs.readFileSync(filename, 'utf-8');
47
+
48
+ let foundMap = await loadSourceMapUrl(fs, filename, contents);
49
+ assert.equal(foundMap.url, 'file://referenced-min.js.map');
50
+ assert.equal(
51
+ foundMap.filename,
52
+ path.join(__dirname, 'input/sourcemap/referenced-min.js.map'),
53
+ );
54
+ assert.deepEqual(foundMap.map, {
55
+ version: 3,
56
+ sources: ['./referenced.js'],
57
+ names: ['hello', 'l', 'o', 'console', 'log'],
58
+ mappings:
59
+ 'AAAA,SAASA,QACP,IAAIC,EAAI,QACNC,EAAI,QACNC,QAAQC,IAAIH,EAAI,IAAMC,EAAI,KAE5BF',
60
+ });
61
+ });
62
+
63
+ it('Should be able to load sourcemap data from an inline url reference', async () => {
64
+ let filename = path.join(__dirname, './input/sourcemap/inline.js');
65
+ let contents = fs.readFileSync(filename, 'utf-8');
66
+
67
+ let foundMap = await loadSourceMapUrl(fs, filename, contents);
68
+ assert.equal(
69
+ foundMap.url,
70
+ 'data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmb28uanMiLCJiYXIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O1VBQ0c7Ozs7Ozs7Ozs7Ozs7O3NCQ0RIO3NCQUNBIn0=',
71
+ );
72
+ assert.equal(foundMap.filename, filename);
73
+ assert.deepEqual(foundMap.map, {
74
+ version: 3,
75
+ file: '',
76
+ sources: ['foo.js', 'bar.js'],
77
+ names: [],
78
+ mappings: ';;;;;;;;;UACG;;;;;;;;;;;;;;sBCDH;sBACA',
79
+ });
80
+ });
81
+
82
+ it('Should be able to load a SourceMap instance from a file', async () => {
83
+ let filename = path.join(__dirname, './input/sourcemap/referenced-min.js');
84
+ let contents = fs.readFileSync(filename, 'utf-8');
85
+
86
+ let map = await loadSourceMap(filename, contents, {
87
+ fs,
88
+ projectRoot: __dirname,
89
+ });
90
+
91
+ assert(!!map);
92
+
93
+ let parsedMap = map.getMap();
94
+ assert.deepEqual(parsedMap.sources, ['input/sourcemap/referenced.js']);
95
+ assert.deepEqual(parsedMap.names, ['hello', 'l', 'o', 'console', 'log']);
96
+ assert.deepEqual(parsedMap.mappings, [
97
+ {
98
+ generated: {line: 1, column: 0},
99
+ original: {line: 1, column: 0},
100
+ source: 0,
101
+ },
102
+ {
103
+ generated: {line: 1, column: 9},
104
+ original: {line: 1, column: 9},
105
+ source: 0,
106
+ name: 0,
107
+ },
108
+ {
109
+ generated: {line: 1, column: 17},
110
+ original: {line: 2, column: 2},
111
+ source: 0,
112
+ },
113
+ {
114
+ generated: {line: 1, column: 21},
115
+ original: {line: 2, column: 6},
116
+ source: 0,
117
+ name: 1,
118
+ },
119
+ {
120
+ generated: {line: 1, column: 23},
121
+ original: {line: 2, column: 10},
122
+ source: 0,
123
+ },
124
+ {
125
+ generated: {line: 1, column: 31},
126
+ original: {line: 3, column: 4},
127
+ source: 0,
128
+ name: 2,
129
+ },
130
+ {
131
+ generated: {line: 1, column: 33},
132
+ original: {line: 3, column: 8},
133
+ source: 0,
134
+ },
135
+ {
136
+ generated: {line: 1, column: 41},
137
+ original: {line: 4, column: 2},
138
+ source: 0,
139
+ name: 3,
140
+ },
141
+ {
142
+ generated: {line: 1, column: 49},
143
+ original: {line: 4, column: 10},
144
+ source: 0,
145
+ name: 4,
146
+ },
147
+ {
148
+ generated: {line: 1, column: 53},
149
+ original: {line: 4, column: 14},
150
+ source: 0,
151
+ name: 1,
152
+ },
153
+ {
154
+ generated: {line: 1, column: 55},
155
+ original: {line: 4, column: 18},
156
+ source: 0,
157
+ },
158
+ {
159
+ generated: {line: 1, column: 59},
160
+ original: {line: 4, column: 24},
161
+ source: 0,
162
+ name: 2,
163
+ },
164
+ {
165
+ generated: {line: 1, column: 61},
166
+ original: {line: 4, column: 28},
167
+ source: 0,
168
+ },
169
+ {
170
+ generated: {line: 1, column: 66},
171
+ original: {line: 6, column: 0},
172
+ source: 0,
173
+ name: 0,
174
+ },
175
+ ]);
176
+ });
177
+
178
+ it('Should remap sources when using sourceRoot', async () => {
179
+ let filename = path.join(__dirname, './input/sourcemap/referenced-min.js');
180
+ let contents = fs.readFileSync(filename, 'utf-8');
181
+
182
+ let map = await loadSourceMap(filename, contents, {
183
+ fs,
184
+ projectRoot: __dirname,
185
+ });
186
+
187
+ assert(!!map);
188
+
189
+ let parsedMap = map.getMap();
190
+ assert.deepEqual(parsedMap.sources, ['input/sourcemap/referenced.js']);
191
+ });
192
+
193
+ it('Should remap sources when using sourceRoot', async () => {
194
+ let filename = path.join(__dirname, './input/sourcemap/source-root.js');
195
+ let contents = fs.readFileSync(filename, 'utf-8');
196
+
197
+ let map = await loadSourceMap(filename, contents, {
198
+ fs,
199
+ projectRoot: __dirname,
200
+ });
201
+
202
+ assert(!!map);
203
+
204
+ let parsedMap = map.getMap();
205
+ assert.deepEqual(parsedMap.sources, ['input/source.js']);
206
+ });
207
+ });
@@ -1,7 +1,6 @@
1
1
  // @flow strict-local
2
2
 
3
3
  import assert from 'assert';
4
- // $FlowFixMe
5
4
  import sinon from 'sinon';
6
5
  import throttle from '../src/throttle';
7
6
 
@@ -35,7 +34,7 @@ describe('throttle', () => {
35
34
 
36
35
  it('preserves the `this` when throttled functions are invoked', () => {
37
36
  let result;
38
- let throttled = throttle(function() {
37
+ let throttled = throttle(function () {
39
38
  result = this.bar;
40
39
  }, 100);
41
40
 
@@ -0,0 +1,37 @@
1
+ // @flow strict-local
2
+
3
+ import assert from 'assert';
4
+ import urlJoin from '../src/urlJoin';
5
+
6
+ describe('urlJoin', () => {
7
+ it('Should join two paths', () => {
8
+ let joinedUrl = urlJoin('/', './image.jpeg?test=test');
9
+ assert.equal(joinedUrl, '/image.jpeg?test=test');
10
+ });
11
+
12
+ it('Should join two paths with longer publicUrl', () => {
13
+ let joinedUrl = urlJoin('/static', './image.jpeg?test=test');
14
+ assert.equal(joinedUrl, '/static/image.jpeg?test=test');
15
+ });
16
+
17
+ it('Should join two paths with longer publicUrl', () => {
18
+ let joinedUrl = urlJoin('/static', 'image.jpeg?test=test');
19
+ assert.equal(joinedUrl, '/static/image.jpeg?test=test');
20
+ });
21
+
22
+ it('Should turn windows path into posix', () => {
23
+ let joinedUrl = urlJoin('/static', '.\\image.jpeg?test=test');
24
+ assert.equal(joinedUrl, '/static/image.jpeg?test=test');
25
+ });
26
+
27
+ it('should support paths with colons', () => {
28
+ let joinedUrl = urlJoin('/static', 'a:b:c.html');
29
+ assert.equal(joinedUrl, '/static/a:b:c.html');
30
+
31
+ joinedUrl = urlJoin('/static', '/a:b:c.html');
32
+ assert.equal(joinedUrl, '/static/a:b:c.html');
33
+
34
+ joinedUrl = urlJoin('/static', './a:b:c.html');
35
+ assert.equal(joinedUrl, '/static/a:b:c.html');
36
+ });
37
+ });
package/lib/DefaultMap.js DELETED
@@ -1,64 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DefaultWeakMap = exports.DefaultMap = void 0;
7
-
8
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
-
10
- class DefaultMap extends Map {
11
- constructor(getDefault, entries) {
12
- super(entries);
13
-
14
- _defineProperty(this, "_getDefault", void 0);
15
-
16
- this._getDefault = getDefault;
17
- }
18
-
19
- get(key) {
20
- let ret;
21
-
22
- if (this.has(key)) {
23
- ret = super.get(key);
24
- } else {
25
- ret = this._getDefault(key);
26
- this.set(key, ret);
27
- } // $FlowFixMe
28
-
29
-
30
- return ret;
31
- }
32
-
33
- } // Duplicated from DefaultMap implementation for Flow
34
- // Roughly mirrors https://github.com/facebook/flow/blob/2eb5a78d92c167117ba9caae070afd2b9f598599/lib/core.js#L617
35
-
36
-
37
- exports.DefaultMap = DefaultMap;
38
-
39
- class DefaultWeakMap extends WeakMap {
40
- constructor(getDefault, entries) {
41
- super(entries);
42
-
43
- _defineProperty(this, "_getDefault", void 0);
44
-
45
- this._getDefault = getDefault;
46
- }
47
-
48
- get(key) {
49
- let ret;
50
-
51
- if (this.has(key)) {
52
- ret = super.get(key);
53
- } else {
54
- ret = this._getDefault(key);
55
- this.set(key, ret);
56
- } // $FlowFixMe
57
-
58
-
59
- return ret;
60
- }
61
-
62
- }
63
-
64
- exports.DefaultWeakMap = DefaultWeakMap;
package/lib/Deferred.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.makeDeferredWithPromise = makeDeferredWithPromise;
7
-
8
- var _assert = _interopRequireDefault(require("assert"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- function makeDeferredWithPromise() {
13
- let deferred;
14
- let promise = new Promise((resolve, reject) => {
15
- deferred = {
16
- resolve,
17
- reject
18
- };
19
- }); // Promise constructor callback executes synchronously, so this is defined
20
-
21
- (0, _assert.default)(deferred != null);
22
- return {
23
- deferred,
24
- promise
25
- };
26
- }