@minecraft/core-build-tasks 1.1.3 → 1.1.5
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/lib/index.js +3 -19
- package/lib/index.js.map +1 -1
- package/lib/index.test.js +4 -6
- package/lib/index.test.js.map +1 -1
- package/lib/platforms/MinecraftProduct.js +2 -5
- package/lib/platforms/MinecraftProduct.js.map +1 -1
- package/lib/platforms/index.js +1 -17
- package/lib/platforms/index.js.map +1 -1
- package/lib/setupEnvironment.js +3 -10
- package/lib/setupEnvironment.js.map +1 -1
- package/lib/tasks/api-extractor.js +4 -8
- package/lib/tasks/api-extractor.js.map +1 -1
- package/lib/tasks/bundle.js +18 -26
- package/lib/tasks/bundle.js.map +1 -1
- package/lib/tasks/bundle.test.js +196 -201
- package/lib/tasks/bundle.test.js.map +1 -1
- package/lib/tasks/clean.js +5 -12
- package/lib/tasks/clean.js.map +1 -1
- package/lib/tasks/cleanCollateral.js +8 -38
- package/lib/tasks/cleanCollateral.js.map +1 -1
- package/lib/tasks/copy.js +11 -18
- package/lib/tasks/copy.js.map +1 -1
- package/lib/tasks/coreLint.js +25 -25
- package/lib/tasks/coreLint.js.map +1 -1
- package/lib/tasks/helpers/copyFiles.js +9 -16
- package/lib/tasks/helpers/copyFiles.js.map +1 -1
- package/lib/tasks/helpers/getGameDeploymentRootPaths.js +12 -40
- package/lib/tasks/helpers/getGameDeploymentRootPaths.js.map +1 -1
- package/lib/tasks/helpers/getOrThrowFromProcess.js +1 -5
- package/lib/tasks/helpers/getOrThrowFromProcess.js.map +1 -1
- package/lib/tasks/helpers/index.js +3 -19
- package/lib/tasks/helpers/index.js.map +1 -1
- package/lib/tasks/index.js +11 -27
- package/lib/tasks/index.js.map +1 -1
- package/lib/tasks/updateWorld.js +12 -19
- package/lib/tasks/updateWorld.js.map +1 -1
- package/lib/tasks/vitest.js +3 -7
- package/lib/tasks/vitest.js.map +1 -1
- package/lib/tasks/watch.js +12 -16
- package/lib/tasks/watch.js.map +1 -1
- package/lib/tasks/zip.js +18 -26
- package/lib/tasks/zip.js.map +1 -1
- package/package.json +10 -2
package/lib/tasks/bundle.test.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright (c) Microsoft Corporation.
|
|
3
2
|
// Licensed under the MIT License.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
const vitest_1 = require("vitest");
|
|
9
|
-
const bundle_1 = require("./bundle");
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { postProcessOutputFiles } from './bundle';
|
|
5
|
+
import path from 'path';
|
|
11
6
|
function _createParameters(sourcemap, outputFile, outputSourcemapPath) {
|
|
12
7
|
return {
|
|
13
8
|
options: {
|
|
@@ -33,312 +28,312 @@ function _createParameters(sourcemap, outputFile, outputSourcemapPath) {
|
|
|
33
28
|
},
|
|
34
29
|
};
|
|
35
30
|
}
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
describe('postProcessOutputFiles with source map files at different path', () => {
|
|
32
|
+
it('sourcemap `true` - Dictionary populated correctly', () => {
|
|
38
33
|
const sourcemap = true;
|
|
39
|
-
const debugPath =
|
|
40
|
-
const outputFile =
|
|
34
|
+
const debugPath = path.resolve('./dist/debug');
|
|
35
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
41
36
|
const parameters = _createParameters(sourcemap, outputFile, debugPath);
|
|
42
|
-
const expectedSourceMapDirectory =
|
|
43
|
-
const expectedOutputDirectory =
|
|
37
|
+
const expectedSourceMapDirectory = path.resolve('./dist/debug');
|
|
38
|
+
const expectedOutputDirectory = path.resolve('./dist/scripts');
|
|
44
39
|
const expectedOutputFilePath = outputFile;
|
|
45
|
-
const expectedSourceMapFilePath =
|
|
40
|
+
const expectedSourceMapFilePath = path.resolve('./dist/debug/main.js.map');
|
|
46
41
|
const expectedSourceMappingURL = '\n//# sourceMappingURL=../debug/main.js.map\n';
|
|
47
42
|
const expectedSourceMapFile = '../scripts/main.js';
|
|
48
|
-
const result =
|
|
49
|
-
|
|
43
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
44
|
+
expect(result).toBeDefined();
|
|
50
45
|
if (result) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
expect(result.outputDirectory).toBe(expectedOutputDirectory);
|
|
47
|
+
expect(result.sourceMapDirectory).toBe(expectedSourceMapDirectory);
|
|
48
|
+
expect(Object.keys(result.generatedFiles).length).toBe(2);
|
|
49
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBeDefined();
|
|
50
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBe(expectedSourceMappingURL);
|
|
51
|
+
expect(result.generatedFiles[expectedSourceMapFilePath]).toBeDefined();
|
|
57
52
|
const sourceMap = JSON.parse(result.generatedFiles[expectedSourceMapFilePath]);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
expect(sourceMap).toBeDefined();
|
|
54
|
+
expect(sourceMap.file).toBeDefined();
|
|
55
|
+
expect(sourceMap.file).toBe(expectedSourceMapFile);
|
|
61
56
|
}
|
|
62
57
|
});
|
|
63
|
-
|
|
58
|
+
it('sourcemap `linked` - Dictionary populated correctly', () => {
|
|
64
59
|
const sourcemap = 'linked';
|
|
65
|
-
const debugPath =
|
|
66
|
-
const outputFile =
|
|
60
|
+
const debugPath = path.resolve('./dist/debug');
|
|
61
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
67
62
|
const parameters = _createParameters(sourcemap, outputFile, debugPath);
|
|
68
|
-
const expectedSourceMapDirectory =
|
|
69
|
-
const expectedOutputDirectory =
|
|
63
|
+
const expectedSourceMapDirectory = path.resolve('./dist/debug');
|
|
64
|
+
const expectedOutputDirectory = path.resolve('./dist/scripts');
|
|
70
65
|
const expectedOutputFilePath = outputFile;
|
|
71
|
-
const expectedSourceMapFilePath =
|
|
66
|
+
const expectedSourceMapFilePath = path.resolve('./dist/debug/main.js.map');
|
|
72
67
|
const expectedSourceMappingURL = '\n//# sourceMappingURL=../debug/main.js.map\n';
|
|
73
68
|
const expectedSourceMapFile = '../scripts/main.js';
|
|
74
|
-
const result =
|
|
75
|
-
|
|
69
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
70
|
+
expect(result).toBeDefined();
|
|
76
71
|
if (result) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
expect(result.outputDirectory).toBe(expectedOutputDirectory);
|
|
73
|
+
expect(result.sourceMapDirectory).toBe(expectedSourceMapDirectory);
|
|
74
|
+
expect(Object.keys(result.generatedFiles).length).toBe(2);
|
|
75
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBeDefined();
|
|
76
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBe(expectedSourceMappingURL);
|
|
77
|
+
expect(result.generatedFiles[expectedSourceMapFilePath]).toBeDefined();
|
|
83
78
|
const sourceMap = JSON.parse(result.generatedFiles[expectedSourceMapFilePath]);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
expect(sourceMap).toBeDefined();
|
|
80
|
+
expect(sourceMap.file).toBeDefined();
|
|
81
|
+
expect(sourceMap.file).toBe(expectedSourceMapFile);
|
|
87
82
|
}
|
|
88
83
|
});
|
|
89
|
-
|
|
84
|
+
it('sourcemap `external` - Dictionary populated correctly', () => {
|
|
90
85
|
const sourcemap = 'external';
|
|
91
|
-
const debugPath =
|
|
92
|
-
const outputFile =
|
|
86
|
+
const debugPath = path.resolve('./dist/debug');
|
|
87
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
93
88
|
const parameters = _createParameters(sourcemap, outputFile, debugPath);
|
|
94
|
-
const expectedSourceMapDirectory =
|
|
95
|
-
const expectedOutputDirectory =
|
|
89
|
+
const expectedSourceMapDirectory = path.resolve('./dist/debug');
|
|
90
|
+
const expectedOutputDirectory = path.resolve('./dist/scripts');
|
|
96
91
|
const expectedOutputFilePath = outputFile;
|
|
97
|
-
const expectedSourceMapFilePath =
|
|
92
|
+
const expectedSourceMapFilePath = path.resolve('./dist/debug/main.js.map');
|
|
98
93
|
const expectedSourceMappingURL = '';
|
|
99
94
|
const expectedSourceMapFile = '../scripts/main.js';
|
|
100
|
-
const result =
|
|
101
|
-
|
|
95
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
96
|
+
expect(result).toBeDefined();
|
|
102
97
|
if (result) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
expect(result.outputDirectory).toBe(expectedOutputDirectory);
|
|
99
|
+
expect(result.sourceMapDirectory).toBe(expectedSourceMapDirectory);
|
|
100
|
+
expect(Object.keys(result.generatedFiles).length).toBe(2);
|
|
101
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBeDefined();
|
|
102
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBe(expectedSourceMappingURL);
|
|
103
|
+
expect(result.generatedFiles[expectedSourceMapFilePath]).toBeDefined();
|
|
109
104
|
const sourceMap = JSON.parse(result.generatedFiles[expectedSourceMapFilePath]);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
105
|
+
expect(sourceMap).toBeDefined();
|
|
106
|
+
expect(sourceMap.file).toBeDefined();
|
|
107
|
+
expect(sourceMap.file).toBe(expectedSourceMapFile);
|
|
113
108
|
}
|
|
114
109
|
});
|
|
115
|
-
|
|
110
|
+
it('sourcemap `both` - Dictionary populated correctly', () => {
|
|
116
111
|
const sourcemap = 'both';
|
|
117
|
-
const debugPath =
|
|
118
|
-
const outputFile =
|
|
112
|
+
const debugPath = path.resolve('./dist/debug');
|
|
113
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
119
114
|
const parameters = _createParameters(sourcemap, outputFile, debugPath);
|
|
120
|
-
const expectedSourceMapDirectory =
|
|
121
|
-
const expectedOutputDirectory =
|
|
115
|
+
const expectedSourceMapDirectory = path.resolve('./dist/debug');
|
|
116
|
+
const expectedOutputDirectory = path.resolve('./dist/scripts');
|
|
122
117
|
const expectedOutputFilePath = outputFile;
|
|
123
|
-
const expectedSourceMapFilePath =
|
|
118
|
+
const expectedSourceMapFilePath = path.resolve('./dist/debug/main.js.map');
|
|
124
119
|
const expectedSourceMappingURL = '';
|
|
125
120
|
const expectedSourceMapFile = '../scripts/main.js';
|
|
126
|
-
const result =
|
|
127
|
-
|
|
121
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
122
|
+
expect(result).toBeDefined();
|
|
128
123
|
if (result) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
expect(result.outputDirectory).toBe(expectedOutputDirectory);
|
|
125
|
+
expect(result.sourceMapDirectory).toBe(expectedSourceMapDirectory);
|
|
126
|
+
expect(Object.keys(result.generatedFiles).length).toBe(2);
|
|
127
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBeDefined();
|
|
128
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBe(expectedSourceMappingURL);
|
|
129
|
+
expect(result.generatedFiles[expectedSourceMapFilePath]).toBeDefined();
|
|
135
130
|
const sourceMap = JSON.parse(result.generatedFiles[expectedSourceMapFilePath]);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
131
|
+
expect(sourceMap).toBeDefined();
|
|
132
|
+
expect(sourceMap.file).toBeDefined();
|
|
133
|
+
expect(sourceMap.file).toBe(expectedSourceMapFile);
|
|
139
134
|
}
|
|
140
135
|
});
|
|
141
|
-
|
|
136
|
+
it('sourcemap `inline` - Dictionary populated correctly', () => {
|
|
142
137
|
const sourcemap = 'inline';
|
|
143
|
-
const debugPath =
|
|
144
|
-
const outputFile =
|
|
138
|
+
const debugPath = path.resolve('./dist/debug');
|
|
139
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
145
140
|
const parameters = _createParameters(sourcemap, outputFile, debugPath);
|
|
146
|
-
const expectedSourceMapDirectory =
|
|
147
|
-
const expectedOutputDirectory =
|
|
141
|
+
const expectedSourceMapDirectory = path.resolve('./dist/debug');
|
|
142
|
+
const expectedOutputDirectory = path.resolve('./dist/scripts');
|
|
148
143
|
const expectedOutputFilePath = outputFile;
|
|
149
|
-
const expectedSourceMapFilePath =
|
|
144
|
+
const expectedSourceMapFilePath = path.resolve('./dist/debug/main.js.map');
|
|
150
145
|
const expectedSourceMappingURL = '';
|
|
151
146
|
const expectedSourceMapFile = '../scripts/main.js';
|
|
152
|
-
const result =
|
|
153
|
-
|
|
147
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
148
|
+
expect(result).toBeDefined();
|
|
154
149
|
if (result) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
150
|
+
expect(result.outputDirectory).toBe(expectedOutputDirectory);
|
|
151
|
+
expect(result.sourceMapDirectory).toBe(expectedSourceMapDirectory);
|
|
152
|
+
expect(Object.keys(result.generatedFiles).length).toBe(2);
|
|
153
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBeDefined();
|
|
154
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBe(expectedSourceMappingURL);
|
|
155
|
+
expect(result.generatedFiles[expectedSourceMapFilePath]).toBeDefined();
|
|
161
156
|
const sourceMap = JSON.parse(result.generatedFiles[expectedSourceMapFilePath]);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
157
|
+
expect(sourceMap).toBeDefined();
|
|
158
|
+
expect(sourceMap.file).toBeDefined();
|
|
159
|
+
expect(sourceMap.file).toBe(expectedSourceMapFile);
|
|
165
160
|
}
|
|
166
161
|
});
|
|
167
162
|
});
|
|
168
|
-
|
|
169
|
-
|
|
163
|
+
describe('postProcessOutputFiles with source map files at same path', () => {
|
|
164
|
+
it('sourcemap `true` - Dictionary populated correctly using undefined', () => {
|
|
170
165
|
const sourcemap = true;
|
|
171
166
|
const debugPath = undefined;
|
|
172
|
-
const outputFile =
|
|
167
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
173
168
|
const parameters = _createParameters(sourcemap, outputFile, debugPath);
|
|
174
|
-
const expectedSourceMapDirectory =
|
|
175
|
-
const expectedOutputDirectory =
|
|
169
|
+
const expectedSourceMapDirectory = path.resolve('./dist/scripts');
|
|
170
|
+
const expectedOutputDirectory = path.resolve('./dist/scripts');
|
|
176
171
|
const expectedOutputFilePath = outputFile;
|
|
177
|
-
const expectedSourceMapFilePath =
|
|
172
|
+
const expectedSourceMapFilePath = path.resolve('./dist/scripts/main.js.map');
|
|
178
173
|
const expectedSourceMappingURL = '\n//# sourceMappingURL=main.js.map\n';
|
|
179
174
|
const expectedSourceMapFile = 'main.js';
|
|
180
|
-
const result =
|
|
181
|
-
|
|
175
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
176
|
+
expect(result).toBeDefined();
|
|
182
177
|
if (result) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
178
|
+
expect(result.outputDirectory).toBe(expectedOutputDirectory);
|
|
179
|
+
expect(result.sourceMapDirectory).toBe(expectedSourceMapDirectory);
|
|
180
|
+
expect(Object.keys(result.generatedFiles).length).toBe(2);
|
|
181
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBeDefined();
|
|
182
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBe(expectedSourceMappingURL);
|
|
183
|
+
expect(result.generatedFiles[expectedSourceMapFilePath]).toBeDefined();
|
|
189
184
|
const sourceMap = JSON.parse(result.generatedFiles[expectedSourceMapFilePath]);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
185
|
+
expect(sourceMap).toBeDefined();
|
|
186
|
+
expect(sourceMap.file).toBeDefined();
|
|
187
|
+
expect(sourceMap.file).toBe(expectedSourceMapFile);
|
|
193
188
|
}
|
|
194
189
|
});
|
|
195
|
-
|
|
190
|
+
it('sourcemap `true` - Dictionary populated correctly using same path explicitly', () => {
|
|
196
191
|
const sourcemap = true;
|
|
197
|
-
const debugPath =
|
|
198
|
-
const outputFile =
|
|
192
|
+
const debugPath = path.resolve('./dist/scripts');
|
|
193
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
199
194
|
const parameters = _createParameters(sourcemap, outputFile, debugPath);
|
|
200
|
-
const expectedSourceMapDirectory =
|
|
201
|
-
const expectedOutputDirectory =
|
|
195
|
+
const expectedSourceMapDirectory = path.resolve('./dist/scripts');
|
|
196
|
+
const expectedOutputDirectory = path.resolve('./dist/scripts');
|
|
202
197
|
const expectedOutputFilePath = outputFile;
|
|
203
|
-
const expectedSourceMapFilePath =
|
|
198
|
+
const expectedSourceMapFilePath = path.resolve('./dist/scripts/main.js.map');
|
|
204
199
|
const expectedSourceMappingURL = '\n//# sourceMappingURL=main.js.map\n';
|
|
205
200
|
const expectedSourceMapFile = 'main.js';
|
|
206
|
-
const result =
|
|
207
|
-
|
|
201
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
202
|
+
expect(result).toBeDefined();
|
|
208
203
|
if (result) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
204
|
+
expect(result.outputDirectory).toBe(expectedOutputDirectory);
|
|
205
|
+
expect(result.sourceMapDirectory).toBe(expectedSourceMapDirectory);
|
|
206
|
+
expect(Object.keys(result.generatedFiles).length).toBe(2);
|
|
207
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBeDefined();
|
|
208
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBe(expectedSourceMappingURL);
|
|
209
|
+
expect(result.generatedFiles[expectedSourceMapFilePath]).toBeDefined();
|
|
215
210
|
const sourceMap = JSON.parse(result.generatedFiles[expectedSourceMapFilePath]);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
211
|
+
expect(sourceMap).toBeDefined();
|
|
212
|
+
expect(sourceMap.file).toBeDefined();
|
|
213
|
+
expect(sourceMap.file).toBe(expectedSourceMapFile);
|
|
219
214
|
}
|
|
220
215
|
});
|
|
221
|
-
|
|
216
|
+
it('sourcemap `linked` - Dictionary populated correctly using undefined', () => {
|
|
222
217
|
const sourcemap = 'linked';
|
|
223
218
|
const debugPath = undefined;
|
|
224
|
-
const outputFile =
|
|
219
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
225
220
|
const parameters = _createParameters(sourcemap, outputFile, debugPath);
|
|
226
|
-
const expectedSourceMapDirectory =
|
|
227
|
-
const expectedOutputDirectory =
|
|
221
|
+
const expectedSourceMapDirectory = path.resolve('./dist/scripts');
|
|
222
|
+
const expectedOutputDirectory = path.resolve('./dist/scripts');
|
|
228
223
|
const expectedOutputFilePath = outputFile;
|
|
229
|
-
const expectedSourceMapFilePath =
|
|
224
|
+
const expectedSourceMapFilePath = path.resolve('./dist/scripts/main.js.map');
|
|
230
225
|
const expectedSourceMappingURL = '\n//# sourceMappingURL=main.js.map\n';
|
|
231
226
|
const expectedSourceMapFile = 'main.js';
|
|
232
|
-
const result =
|
|
233
|
-
|
|
227
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
228
|
+
expect(result).toBeDefined();
|
|
234
229
|
if (result) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
230
|
+
expect(result.outputDirectory).toBe(expectedOutputDirectory);
|
|
231
|
+
expect(result.sourceMapDirectory).toBe(expectedSourceMapDirectory);
|
|
232
|
+
expect(Object.keys(result.generatedFiles).length).toBe(2);
|
|
233
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBeDefined();
|
|
234
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBe(expectedSourceMappingURL);
|
|
235
|
+
expect(result.generatedFiles[expectedSourceMapFilePath]).toBeDefined();
|
|
241
236
|
const sourceMap = JSON.parse(result.generatedFiles[expectedSourceMapFilePath]);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
expect(sourceMap).toBeDefined();
|
|
238
|
+
expect(sourceMap.file).toBeDefined();
|
|
239
|
+
expect(sourceMap.file).toBe(expectedSourceMapFile);
|
|
245
240
|
}
|
|
246
241
|
});
|
|
247
|
-
|
|
242
|
+
it('sourcemap `external` - Dictionary populated correctly using undefined', () => {
|
|
248
243
|
const sourcemap = 'external';
|
|
249
244
|
const debugPath = undefined;
|
|
250
|
-
const outputFile =
|
|
245
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
251
246
|
const parameters = _createParameters(sourcemap, outputFile, debugPath);
|
|
252
|
-
const expectedSourceMapDirectory =
|
|
253
|
-
const expectedOutputDirectory =
|
|
247
|
+
const expectedSourceMapDirectory = path.resolve('./dist/scripts');
|
|
248
|
+
const expectedOutputDirectory = path.resolve('./dist/scripts');
|
|
254
249
|
const expectedOutputFilePath = outputFile;
|
|
255
|
-
const expectedSourceMapFilePath =
|
|
250
|
+
const expectedSourceMapFilePath = path.resolve('./dist/scripts/main.js.map');
|
|
256
251
|
const expectedSourceMappingURL = '';
|
|
257
252
|
const expectedSourceMapFile = 'main.js';
|
|
258
|
-
const result =
|
|
259
|
-
|
|
253
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
254
|
+
expect(result).toBeDefined();
|
|
260
255
|
if (result) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
256
|
+
expect(result.outputDirectory).toBe(expectedOutputDirectory);
|
|
257
|
+
expect(result.sourceMapDirectory).toBe(expectedSourceMapDirectory);
|
|
258
|
+
expect(Object.keys(result.generatedFiles).length).toBe(2);
|
|
259
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBeDefined();
|
|
260
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBe(expectedSourceMappingURL);
|
|
261
|
+
expect(result.generatedFiles[expectedSourceMapFilePath]).toBeDefined();
|
|
267
262
|
const sourceMap = JSON.parse(result.generatedFiles[expectedSourceMapFilePath]);
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
263
|
+
expect(sourceMap).toBeDefined();
|
|
264
|
+
expect(sourceMap.file).toBeDefined();
|
|
265
|
+
expect(sourceMap.file).toBe(expectedSourceMapFile);
|
|
271
266
|
}
|
|
272
267
|
});
|
|
273
|
-
|
|
268
|
+
it('sourcemap `both` - Dictionary populated correctly using undefined', () => {
|
|
274
269
|
const sourcemap = 'both';
|
|
275
270
|
const debugPath = undefined;
|
|
276
|
-
const outputFile =
|
|
271
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
277
272
|
const parameters = _createParameters(sourcemap, outputFile, debugPath);
|
|
278
|
-
const expectedSourceMapDirectory =
|
|
279
|
-
const expectedOutputDirectory =
|
|
273
|
+
const expectedSourceMapDirectory = path.resolve('./dist/scripts');
|
|
274
|
+
const expectedOutputDirectory = path.resolve('./dist/scripts');
|
|
280
275
|
const expectedOutputFilePath = outputFile;
|
|
281
|
-
const expectedSourceMapFilePath =
|
|
276
|
+
const expectedSourceMapFilePath = path.resolve('./dist/scripts/main.js.map');
|
|
282
277
|
const expectedSourceMappingURL = '';
|
|
283
278
|
const expectedSourceMapFile = 'main.js';
|
|
284
|
-
const result =
|
|
285
|
-
|
|
279
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
280
|
+
expect(result).toBeDefined();
|
|
286
281
|
if (result) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
282
|
+
expect(result.outputDirectory).toBe(expectedOutputDirectory);
|
|
283
|
+
expect(result.sourceMapDirectory).toBe(expectedSourceMapDirectory);
|
|
284
|
+
expect(Object.keys(result.generatedFiles).length).toBe(2);
|
|
285
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBeDefined();
|
|
286
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBe(expectedSourceMappingURL);
|
|
287
|
+
expect(result.generatedFiles[expectedSourceMapFilePath]).toBeDefined();
|
|
293
288
|
const sourceMap = JSON.parse(result.generatedFiles[expectedSourceMapFilePath]);
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
289
|
+
expect(sourceMap).toBeDefined();
|
|
290
|
+
expect(sourceMap.file).toBeDefined();
|
|
291
|
+
expect(sourceMap.file).toBe(expectedSourceMapFile);
|
|
297
292
|
}
|
|
298
293
|
});
|
|
299
|
-
|
|
294
|
+
it('sourcemap `inline` - Dictionary populated correctly using undefined', () => {
|
|
300
295
|
const sourcemap = 'inline';
|
|
301
296
|
const debugPath = undefined;
|
|
302
|
-
const outputFile =
|
|
297
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
303
298
|
const parameters = _createParameters(sourcemap, outputFile, debugPath);
|
|
304
|
-
const expectedSourceMapDirectory =
|
|
305
|
-
const expectedOutputDirectory =
|
|
299
|
+
const expectedSourceMapDirectory = path.resolve('./dist/scripts');
|
|
300
|
+
const expectedOutputDirectory = path.resolve('./dist/scripts');
|
|
306
301
|
const expectedOutputFilePath = outputFile;
|
|
307
|
-
const expectedSourceMapFilePath =
|
|
302
|
+
const expectedSourceMapFilePath = path.resolve('./dist/scripts/main.js.map');
|
|
308
303
|
const expectedSourceMappingURL = '';
|
|
309
304
|
const expectedSourceMapFile = 'main.js';
|
|
310
|
-
const result =
|
|
311
|
-
|
|
305
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
306
|
+
expect(result).toBeDefined();
|
|
312
307
|
if (result) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
308
|
+
expect(result.outputDirectory).toBe(expectedOutputDirectory);
|
|
309
|
+
expect(result.sourceMapDirectory).toBe(expectedSourceMapDirectory);
|
|
310
|
+
expect(Object.keys(result.generatedFiles).length).toBe(2);
|
|
311
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBeDefined();
|
|
312
|
+
expect(result.generatedFiles[expectedOutputFilePath]).toBe(expectedSourceMappingURL);
|
|
313
|
+
expect(result.generatedFiles[expectedSourceMapFilePath]).toBeDefined();
|
|
319
314
|
const sourceMap = JSON.parse(result.generatedFiles[expectedSourceMapFilePath]);
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
315
|
+
expect(sourceMap).toBeDefined();
|
|
316
|
+
expect(sourceMap.file).toBeDefined();
|
|
317
|
+
expect(sourceMap.file).toBe(expectedSourceMapFile);
|
|
323
318
|
}
|
|
324
319
|
});
|
|
325
320
|
});
|
|
326
|
-
|
|
327
|
-
|
|
321
|
+
describe('postProcessOutputFiles with no files', () => {
|
|
322
|
+
it('sourcemap `true` - Returns undefined', () => {
|
|
328
323
|
const sourcemap = true;
|
|
329
|
-
const outputFile =
|
|
324
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
330
325
|
const parameters = _createParameters(sourcemap, outputFile, undefined);
|
|
331
326
|
parameters.buildResult.outputFiles = undefined;
|
|
332
|
-
const result =
|
|
333
|
-
|
|
327
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
328
|
+
expect(result).toBeUndefined();
|
|
334
329
|
});
|
|
335
|
-
|
|
330
|
+
it('sourcemap `false` - Returns undefined', () => {
|
|
336
331
|
const sourcemap = false;
|
|
337
|
-
const outputFile =
|
|
332
|
+
const outputFile = path.resolve('./dist/scripts/main.js');
|
|
338
333
|
const parameters = _createParameters(sourcemap, outputFile, undefined);
|
|
339
334
|
parameters.buildResult.outputFiles = undefined;
|
|
340
|
-
const result =
|
|
341
|
-
|
|
335
|
+
const result = postProcessOutputFiles(parameters.options, parameters.buildResult);
|
|
336
|
+
expect(result).toBeUndefined();
|
|
342
337
|
});
|
|
343
338
|
});
|
|
344
339
|
//# sourceMappingURL=bundle.test.js.map
|