@vizhub/runtime 0.0.1 → 0.0.3
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/dist/assets/setupV3Runtime-BVr5lyKp.js +240 -0
- package/dist/computeSrcDoc.d.ts +13 -0
- package/dist/computeSrcDoc.d.ts.map +1 -0
- package/{src/index.ts → dist/index.d.ts} +1 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/v2Runtime/bundle/rollup.browser.js → dist/index.js} +9286 -12810
- package/dist/useRuntime.d.ts +13 -0
- package/dist/useRuntime.d.ts.map +1 -0
- package/dist/v2Runtime/bundle/bubleJSXOnly.d.ts +5 -0
- package/dist/v2Runtime/bundle/bubleJSXOnly.d.ts.map +1 -0
- package/dist/v2Runtime/bundle/packageJson.d.ts +10 -0
- package/dist/v2Runtime/bundle/packageJson.d.ts.map +1 -0
- package/dist/v2Runtime/computeSrcDocV2.d.ts +3 -0
- package/dist/v2Runtime/computeSrcDocV2.d.ts.map +1 -0
- package/dist/v2Runtime/computeSrcDocV2.test.d.ts +2 -0
- package/dist/v2Runtime/computeSrcDocV2.test.d.ts.map +1 -0
- package/dist/v2Runtime/getComputedIndexHtml.d.ts +4 -0
- package/dist/v2Runtime/getComputedIndexHtml.d.ts.map +1 -0
- package/dist/v2Runtime/getComputedIndexHtml.test.d.ts +2 -0
- package/dist/v2Runtime/getComputedIndexHtml.test.d.ts.map +1 -0
- package/dist/v2Runtime/getText.d.ts +3 -0
- package/dist/v2Runtime/getText.d.ts.map +1 -0
- package/dist/v2Runtime/transformFiles.d.ts +3 -0
- package/dist/v2Runtime/transformFiles.d.ts.map +1 -0
- package/dist/v2Runtime/v3FilesToV2Files.d.ts +3 -0
- package/dist/v2Runtime/v3FilesToV2Files.d.ts.map +1 -0
- package/dist/v2Runtime/v3FilesToV2Files.test.d.ts +2 -0
- package/dist/v2Runtime/v3FilesToV2Files.test.d.ts.map +1 -0
- package/dist/v3Runtime/build.d.ts +14 -0
- package/dist/v3Runtime/build.d.ts.map +1 -0
- package/dist/v3Runtime/build.test.d.ts +2 -0
- package/dist/v3Runtime/build.test.d.ts.map +1 -0
- package/dist/v3Runtime/cleanRollupErrorMessage.d.ts +5 -0
- package/dist/v3Runtime/cleanRollupErrorMessage.d.ts.map +1 -0
- package/dist/v3Runtime/computeSrcDocV3.d.ts +7 -0
- package/dist/v3Runtime/computeSrcDocV3.d.ts.map +1 -0
- package/dist/v3Runtime/extractVizImport.d.ts +7 -0
- package/dist/v3Runtime/extractVizImport.d.ts.map +1 -0
- package/dist/v3Runtime/extractVizImport.test.d.ts +2 -0
- package/dist/v3Runtime/extractVizImport.test.d.ts.map +1 -0
- package/dist/v3Runtime/generateRollupErrorMessage.d.ts +5 -0
- package/dist/v3Runtime/generateRollupErrorMessage.d.ts.map +1 -0
- package/dist/v3Runtime/importFromViz.d.ts +1 -0
- package/dist/v3Runtime/importFromViz.d.ts.map +1 -0
- package/{src/v3Runtime/index.ts → dist/v3Runtime/index.d.ts} +1 -0
- package/dist/v3Runtime/index.d.ts.map +1 -0
- package/dist/v3Runtime/parseId.d.ts +7 -0
- package/dist/v3Runtime/parseId.d.ts.map +1 -0
- package/dist/v3Runtime/setupV3Runtime.d.ts +15 -0
- package/dist/v3Runtime/setupV3Runtime.d.ts.map +1 -0
- package/dist/v3Runtime/transformDSV/index.d.ts +3 -0
- package/dist/v3Runtime/transformDSV/index.d.ts.map +1 -0
- package/dist/v3Runtime/transformSvelte.d.ts +6 -0
- package/dist/v3Runtime/transformSvelte.d.ts.map +1 -0
- package/dist/v3Runtime/types.d.ts +65 -0
- package/dist/v3Runtime/types.d.ts.map +1 -0
- package/dist/v3Runtime/urlLoad.d.ts +1 -0
- package/dist/v3Runtime/urlLoad.d.ts.map +1 -0
- package/dist/v3Runtime/virtual.d.ts +1 -0
- package/dist/v3Runtime/virtual.d.ts.map +1 -0
- package/dist/v3Runtime/vizCache.d.ts +11 -0
- package/dist/v3Runtime/vizCache.d.ts.map +1 -0
- package/dist/v3Runtime/vizCache.test.d.ts +2 -0
- package/dist/v3Runtime/vizCache.test.d.ts.map +1 -0
- package/dist/v3Runtime/vizLoad.d.ts +8 -0
- package/dist/v3Runtime/vizLoad.d.ts.map +1 -0
- package/dist/v3Runtime/vizLoadSvelte.d.ts +1 -0
- package/dist/v3Runtime/vizLoadSvelte.d.ts.map +1 -0
- package/dist/v3Runtime/vizResolve.d.ts +10 -0
- package/dist/v3Runtime/vizResolve.d.ts.map +1 -0
- package/dist/v3Runtime/worker.d.ts +2 -0
- package/dist/v3Runtime/worker.d.ts.map +1 -0
- package/package.json +13 -6
- package/src/computeSrcDoc.ts +0 -68
- package/src/useRuntime.ts +0 -394
- package/src/v2Runtime/bundle/bubleJSXOnly.ts +0 -34
- package/src/v2Runtime/bundle/getLibraries.js +0 -31
- package/src/v2Runtime/bundle/hypothetical.js +0 -232
- package/src/v2Runtime/bundle/index.js +0 -88
- package/src/v2Runtime/bundle/packageJson.ts +0 -49
- package/src/v2Runtime/bundle.test.js +0 -151
- package/src/v2Runtime/computeSrcDocV2.test.ts +0 -163
- package/src/v2Runtime/computeSrcDocV2.ts +0 -34
- package/src/v2Runtime/getComputedIndexHtml.test.ts +0 -33
- package/src/v2Runtime/getComputedIndexHtml.ts +0 -106
- package/src/v2Runtime/getText.ts +0 -19
- package/src/v2Runtime/magicSandbox.js +0 -291
- package/src/v2Runtime/packageJson.js +0 -42
- package/src/v2Runtime/transformFiles.test.js +0 -18
- package/src/v2Runtime/transformFiles.ts +0 -15
- package/src/v2Runtime/v3FilesToV2Files.test.ts +0 -20
- package/src/v2Runtime/v3FilesToV2Files.ts +0 -14
- package/src/v3Runtime/build.test.ts +0 -474
- package/src/v3Runtime/build.ts +0 -270
- package/src/v3Runtime/cleanRollupErrorMessage.ts +0 -15
- package/src/v3Runtime/computeSrcDocV3.ts +0 -151
- package/src/v3Runtime/extractVizImport.test.ts +0 -41
- package/src/v3Runtime/extractVizImport.ts +0 -34
- package/src/v3Runtime/generateRollupErrorMessage.ts +0 -84
- package/src/v3Runtime/importFromViz.ts +0 -36
- package/src/v3Runtime/parseId.ts +0 -14
- package/src/v3Runtime/setupV3Runtime.ts +0 -478
- package/src/v3Runtime/transformDSV/d3-dsv-custom-build/bundle-modified-src.js +0 -121
- package/src/v3Runtime/transformDSV/d3-dsv-custom-build/bundle-modified.js +0 -121
- package/src/v3Runtime/transformDSV/d3-dsv-custom-build/bundle.js +0 -239
- package/src/v3Runtime/transformDSV/d3-dsv-custom-build/index.js +0 -1
- package/src/v3Runtime/transformDSV/d3-dsv-custom-build/package-lock.json +0 -475
- package/src/v3Runtime/transformDSV/d3-dsv-custom-build/package.json +0 -19
- package/src/v3Runtime/transformDSV/d3-dsv-custom-build/rollup.config.js +0 -9
- package/src/v3Runtime/transformDSV/index.ts +0 -71
- package/src/v3Runtime/transformSvelte.ts +0 -111
- package/src/v3Runtime/types.ts +0 -158
- package/src/v3Runtime/urlLoad.ts +0 -33
- package/src/v3Runtime/virtual.ts +0 -27
- package/src/v3Runtime/vizCache.test.ts +0 -126
- package/src/v3Runtime/vizCache.ts +0 -60
- package/src/v3Runtime/vizLoad.ts +0 -68
- package/src/v3Runtime/vizLoadSvelte.ts +0 -46
- package/src/v3Runtime/vizResolve.ts +0 -100
- package/src/v3Runtime/worker.ts +0 -231
@@ -1,474 +0,0 @@
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
2
|
-
import { missingIndexJSError } from 'gateways';
|
3
|
-
import { compile } from 'svelte/compiler';
|
4
|
-
import { rollup } from 'rollup';
|
5
|
-
import { build } from './build';
|
6
|
-
import { createVizCache } from './vizCache';
|
7
|
-
import {
|
8
|
-
sampleContent,
|
9
|
-
sampleContentWithCSS,
|
10
|
-
sampleContentVizImport,
|
11
|
-
sampleContentVizImportWithCSS,
|
12
|
-
sampleContentWithCSV,
|
13
|
-
sampleContentVizImportSlug,
|
14
|
-
sampleContentWithCSVStrangeCharacters,
|
15
|
-
sampleContentSvelte,
|
16
|
-
} from 'entities/test/fixtures';
|
17
|
-
import { VizId } from 'entities';
|
18
|
-
import { missingImportError } from 'gateways/src/errors';
|
19
|
-
|
20
|
-
describe('v3 build', () => {
|
21
|
-
it('Should throw an error when missing files', async () => {
|
22
|
-
// Expect build to throw an error
|
23
|
-
expect(async () => {
|
24
|
-
await build({
|
25
|
-
vizId: 'test-viz',
|
26
|
-
rollup,
|
27
|
-
vizCache: createVizCache({
|
28
|
-
initialContents: [
|
29
|
-
{
|
30
|
-
id: 'test-viz',
|
31
|
-
|
32
|
-
// This test is mainly testing the case
|
33
|
-
// where this is empty.
|
34
|
-
files: {},
|
35
|
-
|
36
|
-
title: 'Test Viz',
|
37
|
-
},
|
38
|
-
],
|
39
|
-
handleCacheMiss: async () => {
|
40
|
-
throw new Error('Not implemented');
|
41
|
-
},
|
42
|
-
}),
|
43
|
-
resolveSlug: () => {
|
44
|
-
throw new Error('Not implemented');
|
45
|
-
},
|
46
|
-
});
|
47
|
-
}).rejects.toThrow(missingIndexJSError());
|
48
|
-
});
|
49
|
-
|
50
|
-
it('Should build successfully with valid inputs', async () => {
|
51
|
-
const vizCache = createVizCache({
|
52
|
-
initialContents: [sampleContent],
|
53
|
-
handleCacheMiss: async () => {
|
54
|
-
throw new Error('Not implemented');
|
55
|
-
},
|
56
|
-
});
|
57
|
-
const buildResult = await build({
|
58
|
-
vizId: sampleContent.id,
|
59
|
-
rollup,
|
60
|
-
vizCache,
|
61
|
-
resolveSlug: () => {
|
62
|
-
throw new Error('Not implemented');
|
63
|
-
},
|
64
|
-
});
|
65
|
-
expect(buildResult).toBeDefined();
|
66
|
-
expect(buildResult.warnings).toHaveLength(0);
|
67
|
-
expect(buildResult.cssFiles).toHaveLength(0);
|
68
|
-
expect(buildResult.src).toBeDefined();
|
69
|
-
expect(buildResult.time).toBeDefined();
|
70
|
-
expect(buildResult.pkg).toBeUndefined();
|
71
|
-
|
72
|
-
expect(buildResult.src).toContain(
|
73
|
-
`const innerMessage = "Inner";`,
|
74
|
-
);
|
75
|
-
expect(buildResult.src).toContain(
|
76
|
-
`const message = "Outer " + innerMessage;`,
|
77
|
-
);
|
78
|
-
});
|
79
|
-
|
80
|
-
it('Should build successfully with css imports', async () => {
|
81
|
-
const vizCache = createVizCache({
|
82
|
-
initialContents: [sampleContentWithCSS],
|
83
|
-
handleCacheMiss: async () => {
|
84
|
-
throw new Error('Not implemented');
|
85
|
-
},
|
86
|
-
});
|
87
|
-
const buildResult = await build({
|
88
|
-
vizId: sampleContentWithCSS.id,
|
89
|
-
rollup,
|
90
|
-
vizCache,
|
91
|
-
resolveSlug: () => {
|
92
|
-
throw new Error('Not implemented');
|
93
|
-
},
|
94
|
-
});
|
95
|
-
// console.log(JSON.stringify(buildResult, null, 2));
|
96
|
-
|
97
|
-
expect(buildResult).toBeDefined();
|
98
|
-
expect(buildResult.warnings).toHaveLength(1);
|
99
|
-
expect(buildResult.cssFiles).toHaveLength(1);
|
100
|
-
expect(buildResult.src).toBeDefined();
|
101
|
-
expect(buildResult.time).toBeDefined();
|
102
|
-
expect(buildResult.pkg).toBeUndefined();
|
103
|
-
|
104
|
-
expect(buildResult.warnings[0].code).toBe(
|
105
|
-
'EMPTY_BUNDLE',
|
106
|
-
);
|
107
|
-
expect(buildResult.cssFiles[0]).toBe(
|
108
|
-
`${sampleContentWithCSS.id}/styles.css`,
|
109
|
-
);
|
110
|
-
});
|
111
|
-
|
112
|
-
it('Should build successfully with csv imports', async () => {
|
113
|
-
const vizCache = createVizCache({
|
114
|
-
initialContents: [sampleContentWithCSV],
|
115
|
-
handleCacheMiss: async () => {
|
116
|
-
throw new Error('Not implemented');
|
117
|
-
},
|
118
|
-
});
|
119
|
-
const buildResult = await build({
|
120
|
-
vizId: sampleContentWithCSV.id,
|
121
|
-
rollup,
|
122
|
-
vizCache,
|
123
|
-
resolveSlug: () => {
|
124
|
-
throw new Error('Not implemented');
|
125
|
-
},
|
126
|
-
});
|
127
|
-
|
128
|
-
// console.log(JSON.stringify(buildResult, null, 2));
|
129
|
-
|
130
|
-
expect(buildResult).toBeDefined();
|
131
|
-
expect(buildResult.warnings).toHaveLength(0);
|
132
|
-
expect(buildResult.cssFiles).toHaveLength(0);
|
133
|
-
expect(buildResult.src).toBeDefined();
|
134
|
-
expect(buildResult.time).toBeDefined();
|
135
|
-
expect(buildResult.pkg).toBeUndefined();
|
136
|
-
|
137
|
-
expect(buildResult.src).toContain('sepal.width');
|
138
|
-
});
|
139
|
-
|
140
|
-
it('Should build successfully with csv imports, strange characters', async () => {
|
141
|
-
const vizCache = createVizCache({
|
142
|
-
initialContents: [
|
143
|
-
sampleContentWithCSVStrangeCharacters,
|
144
|
-
],
|
145
|
-
handleCacheMiss: async () => {
|
146
|
-
throw new Error('Not implemented');
|
147
|
-
},
|
148
|
-
});
|
149
|
-
const buildResult = await build({
|
150
|
-
vizId: sampleContentWithCSVStrangeCharacters.id,
|
151
|
-
rollup,
|
152
|
-
vizCache,
|
153
|
-
resolveSlug: () => {
|
154
|
-
throw new Error('Not implemented');
|
155
|
-
},
|
156
|
-
});
|
157
|
-
|
158
|
-
// console.log(JSON.stringify(buildResult, null, 2));
|
159
|
-
|
160
|
-
expect(buildResult).toBeDefined();
|
161
|
-
expect(buildResult.warnings).toHaveLength(0);
|
162
|
-
expect(buildResult.cssFiles).toHaveLength(0);
|
163
|
-
expect(buildResult.src).toBeDefined();
|
164
|
-
expect(buildResult.time).toBeDefined();
|
165
|
-
expect(buildResult.pkg).toBeUndefined();
|
166
|
-
|
167
|
-
expect(buildResult.src).toContain('Türkiye');
|
168
|
-
});
|
169
|
-
|
170
|
-
it('Import from viz: should build successfully with valid inputs', async () => {
|
171
|
-
const vizCache = createVizCache({
|
172
|
-
initialContents: [
|
173
|
-
sampleContent,
|
174
|
-
sampleContentVizImport,
|
175
|
-
],
|
176
|
-
handleCacheMiss: async () => {
|
177
|
-
throw new Error('Not implemented');
|
178
|
-
},
|
179
|
-
});
|
180
|
-
const buildResult = await build({
|
181
|
-
vizId: sampleContentVizImport.id,
|
182
|
-
rollup,
|
183
|
-
vizCache,
|
184
|
-
resolveSlug: () => {
|
185
|
-
throw new Error('Not implemented');
|
186
|
-
},
|
187
|
-
});
|
188
|
-
|
189
|
-
// console.log(JSON.stringify(buildResult, null, 2));
|
190
|
-
|
191
|
-
expect(buildResult).toBeDefined();
|
192
|
-
expect(buildResult.warnings).toHaveLength(0);
|
193
|
-
expect(buildResult.cssFiles).toHaveLength(0);
|
194
|
-
expect(buildResult.src).toBeDefined();
|
195
|
-
expect(buildResult.time).toBeDefined();
|
196
|
-
expect(buildResult.pkg).toBeUndefined();
|
197
|
-
|
198
|
-
expect(buildResult.src).toContain(
|
199
|
-
`const innerMessage = "Inner";`,
|
200
|
-
);
|
201
|
-
expect(buildResult.src).toContain(
|
202
|
-
`const message = "Outer " + innerMessage;`,
|
203
|
-
);
|
204
|
-
expect(buildResult.src).toContain(
|
205
|
-
`const message2 = "Imported from viz: " + message;`,
|
206
|
-
);
|
207
|
-
});
|
208
|
-
|
209
|
-
it('Import from viz: should build successfully with css imports', async () => {
|
210
|
-
const vizCache = createVizCache({
|
211
|
-
initialContents: [
|
212
|
-
sampleContentWithCSS,
|
213
|
-
sampleContentVizImportWithCSS,
|
214
|
-
],
|
215
|
-
handleCacheMiss: async () => {
|
216
|
-
throw new Error('Not implemented');
|
217
|
-
},
|
218
|
-
});
|
219
|
-
const buildResult = await build({
|
220
|
-
vizId: sampleContentVizImportWithCSS.id,
|
221
|
-
rollup,
|
222
|
-
vizCache,
|
223
|
-
resolveSlug: () => {
|
224
|
-
throw new Error('Not implemented');
|
225
|
-
},
|
226
|
-
});
|
227
|
-
|
228
|
-
// console.log(JSON.stringify(buildResult, null, 2));
|
229
|
-
|
230
|
-
expect(buildResult).toBeDefined();
|
231
|
-
expect(buildResult.warnings).toHaveLength(1);
|
232
|
-
expect(buildResult.cssFiles).toHaveLength(1);
|
233
|
-
expect(buildResult.src).toBeDefined();
|
234
|
-
expect(buildResult.time).toBeDefined();
|
235
|
-
expect(buildResult.pkg).toBeUndefined();
|
236
|
-
|
237
|
-
expect(buildResult.warnings[0].code).toBe(
|
238
|
-
'EMPTY_BUNDLE',
|
239
|
-
);
|
240
|
-
expect(buildResult.cssFiles[0]).toBe(
|
241
|
-
`${sampleContentWithCSS.id}/styles.css`,
|
242
|
-
);
|
243
|
-
});
|
244
|
-
|
245
|
-
it('Import from viz: should build successfully with slug-based import', async () => {
|
246
|
-
const vizCache = createVizCache({
|
247
|
-
initialContents: [
|
248
|
-
sampleContent,
|
249
|
-
sampleContentVizImportSlug,
|
250
|
-
],
|
251
|
-
handleCacheMiss: async () => {
|
252
|
-
throw new Error('Not implemented');
|
253
|
-
},
|
254
|
-
});
|
255
|
-
const buildResult = await build({
|
256
|
-
vizId: sampleContentVizImportSlug.id,
|
257
|
-
rollup,
|
258
|
-
vizCache,
|
259
|
-
resolveSlug: async ({
|
260
|
-
userName,
|
261
|
-
slug,
|
262
|
-
}): Promise<VizId> => {
|
263
|
-
console.log(
|
264
|
-
`Resolving ${userName}/${slug} to ${sampleContent.id}`,
|
265
|
-
);
|
266
|
-
return sampleContent.id;
|
267
|
-
},
|
268
|
-
});
|
269
|
-
|
270
|
-
// console.log(JSON.stringify(buildResult, null, 2));
|
271
|
-
|
272
|
-
expect(buildResult).toBeDefined();
|
273
|
-
expect(buildResult.warnings).toHaveLength(0);
|
274
|
-
expect(buildResult.cssFiles).toHaveLength(0);
|
275
|
-
expect(buildResult.src).toBeDefined();
|
276
|
-
expect(buildResult.time).toBeDefined();
|
277
|
-
expect(buildResult.pkg).toBeUndefined();
|
278
|
-
|
279
|
-
expect(buildResult.src).toContain(
|
280
|
-
`const innerMessage = "Inner";`,
|
281
|
-
);
|
282
|
-
expect(buildResult.src).toContain(
|
283
|
-
`const message = "Outer " + innerMessage;`,
|
284
|
-
);
|
285
|
-
expect(buildResult.src).toContain(
|
286
|
-
`const message2 = "Imported from viz: " + message;`,
|
287
|
-
);
|
288
|
-
});
|
289
|
-
|
290
|
-
it('Svelte: should build successfully with Svelte', async () => {
|
291
|
-
const vizCache = createVizCache({
|
292
|
-
initialContents: [sampleContentSvelte],
|
293
|
-
handleCacheMiss: async () => {
|
294
|
-
throw new Error('Not implemented');
|
295
|
-
},
|
296
|
-
});
|
297
|
-
const buildResult = await build({
|
298
|
-
vizId: sampleContentSvelte.id,
|
299
|
-
rollup,
|
300
|
-
vizCache,
|
301
|
-
getSvelteCompiler: async () => compile,
|
302
|
-
});
|
303
|
-
|
304
|
-
// console.log(JSON.stringify(buildResult, null, 2));
|
305
|
-
// console.log('buildResult.errors');
|
306
|
-
// console.log(buildResult.errors);
|
307
|
-
// console.log('buildResult.warnings');
|
308
|
-
// console.log(buildResult.warnings);
|
309
|
-
// console.log('buildResult.src');
|
310
|
-
// console.log(buildResult.src);
|
311
|
-
|
312
|
-
expect(buildResult).toBeDefined();
|
313
|
-
expect(buildResult.warnings).toHaveLength(0);
|
314
|
-
expect(buildResult.cssFiles).toHaveLength(0);
|
315
|
-
expect(buildResult.src).toBeDefined();
|
316
|
-
expect(buildResult.time).toBeDefined();
|
317
|
-
expect(buildResult.pkg).toBeUndefined();
|
318
|
-
|
319
|
-
// expect(buildResult.src).toContain(
|
320
|
-
// `const innerMessage = "Inner";`,
|
321
|
-
// );
|
322
|
-
// expect(buildResult.src).toContain(
|
323
|
-
// `const message = "Outer " + innerMessage;`,
|
324
|
-
// );
|
325
|
-
// expect(buildResult.src).toContain(
|
326
|
-
// `const message2 = "Imported from viz: " + message;`,
|
327
|
-
// );
|
328
|
-
});
|
329
|
-
|
330
|
-
it('Should throw an error when a package name import is missing', async () => {
|
331
|
-
// Expect build to throw an error
|
332
|
-
expect(async () => {
|
333
|
-
await build({
|
334
|
-
vizId: 'test-viz',
|
335
|
-
rollup,
|
336
|
-
vizCache: createVizCache({
|
337
|
-
initialContents: [
|
338
|
-
{
|
339
|
-
id: 'test-viz',
|
340
|
-
files: {
|
341
|
-
'4325432': {
|
342
|
-
name: 'index.js',
|
343
|
-
text: 'import { message } from "missing-viz";\nconsole.log(message);',
|
344
|
-
},
|
345
|
-
},
|
346
|
-
title: 'Test Viz',
|
347
|
-
},
|
348
|
-
],
|
349
|
-
handleCacheMiss: async () => {
|
350
|
-
throw new Error('Not implemented');
|
351
|
-
},
|
352
|
-
}),
|
353
|
-
resolveSlug: () => {
|
354
|
-
throw new Error('Not implemented');
|
355
|
-
},
|
356
|
-
});
|
357
|
-
}).rejects.toThrow(
|
358
|
-
missingImportError(
|
359
|
-
`"missing-viz" is imported by "test-viz/index.js", but could not be resolved.`,
|
360
|
-
),
|
361
|
-
);
|
362
|
-
});
|
363
|
-
|
364
|
-
it('Should throw an error when a local import is missing', async () => {
|
365
|
-
// Expect build to throw an error
|
366
|
-
expect(async () => {
|
367
|
-
await build({
|
368
|
-
vizId: 'test-viz',
|
369
|
-
rollup,
|
370
|
-
vizCache: createVizCache({
|
371
|
-
initialContents: [
|
372
|
-
{
|
373
|
-
id: 'test-viz',
|
374
|
-
files: {
|
375
|
-
'4325432': {
|
376
|
-
name: 'index.js',
|
377
|
-
text: 'import { message } from "./missing";\nconsole.log(message);',
|
378
|
-
},
|
379
|
-
},
|
380
|
-
title: 'Test Viz',
|
381
|
-
},
|
382
|
-
],
|
383
|
-
handleCacheMiss: async () => {
|
384
|
-
throw new Error('Not implemented');
|
385
|
-
},
|
386
|
-
}),
|
387
|
-
resolveSlug: () => {
|
388
|
-
throw new Error('Not implemented');
|
389
|
-
},
|
390
|
-
});
|
391
|
-
}).rejects.toThrow(
|
392
|
-
missingImportError(
|
393
|
-
`Could not load test-viz/missing.js (imported by test-viz/index.js): Imported file "missing.js" not found.`,
|
394
|
-
),
|
395
|
-
);
|
396
|
-
});
|
397
|
-
it('Should throw an error when a local import is missing', async () => {
|
398
|
-
// Expect build to throw an error
|
399
|
-
expect(async () => {
|
400
|
-
await build({
|
401
|
-
vizId: '7f0b69fcb754479699172d1887817027',
|
402
|
-
rollup,
|
403
|
-
vizCache: createVizCache({
|
404
|
-
initialContents: [
|
405
|
-
{
|
406
|
-
id: '7f0b69fcb754479699172d1887817027',
|
407
|
-
files: {
|
408
|
-
'4325432': {
|
409
|
-
name: 'index.js',
|
410
|
-
text: 'import { message } from "./missing";\nconsole.log(message);',
|
411
|
-
},
|
412
|
-
},
|
413
|
-
title: 'Test Viz',
|
414
|
-
},
|
415
|
-
],
|
416
|
-
handleCacheMiss: async () => {
|
417
|
-
throw new Error('Not implemented');
|
418
|
-
},
|
419
|
-
}),
|
420
|
-
resolveSlug: () => {
|
421
|
-
throw new Error('Not implemented');
|
422
|
-
},
|
423
|
-
});
|
424
|
-
}).rejects.toThrow(
|
425
|
-
missingImportError(
|
426
|
-
`Could not load missing.js (imported by index.js): Imported file "missing.js" not found.`,
|
427
|
-
),
|
428
|
-
);
|
429
|
-
});
|
430
|
-
|
431
|
-
// This is the error that fucked up the whole system
|
432
|
-
// See
|
433
|
-
// https://github.com/rollup/rollup/issues/5379
|
434
|
-
it.skip('Should throw a syntax error properly', async () => {
|
435
|
-
// Expect build to throw an error
|
436
|
-
expect(async () => {
|
437
|
-
await build({
|
438
|
-
vizId: '7f0b69fcb754479699172d1887817027',
|
439
|
-
rollup,
|
440
|
-
vizCache: createVizCache({
|
441
|
-
initialContents: [
|
442
|
-
{
|
443
|
-
id: '7f0b69fcb754479699172d1887817027',
|
444
|
-
files: {
|
445
|
-
'4325432': {
|
446
|
-
name: 'index.js',
|
447
|
-
text: `
|
448
|
-
const foo = {
|
449
|
-
bar = baz,
|
450
|
-
};
|
451
|
-
console.log(foo);
|
452
|
-
`,
|
453
|
-
},
|
454
|
-
},
|
455
|
-
title: 'Test Viz',
|
456
|
-
},
|
457
|
-
],
|
458
|
-
handleCacheMiss: async () => {
|
459
|
-
throw new Error('Not implemented');
|
460
|
-
},
|
461
|
-
}),
|
462
|
-
resolveSlug: () => {
|
463
|
-
throw new Error('Not implemented');
|
464
|
-
},
|
465
|
-
});
|
466
|
-
}).rejects.toThrow(
|
467
|
-
missingImportError(
|
468
|
-
`Could not load missing.js (imported by index.js): Imported file "missing.js" not found.`,
|
469
|
-
),
|
470
|
-
);
|
471
|
-
});
|
472
|
-
|
473
|
-
// TODO test that covers invalidPackageJSONError
|
474
|
-
});
|