|
1 |
| -/* eslint-disable no-console */ |
2 |
| -const fs = require('fs'); |
3 |
| -const path = require('path'); |
4 |
| - |
5 |
| -const webpack = require('webpack'); |
6 |
| -const { JSDOM } = require('jsdom'); |
7 |
| - |
8 |
| -webpack( |
9 |
| - { |
10 |
| - entry: path.join(__dirname, 'test-code.js'), |
11 |
| - output: { |
12 |
| - path: __dirname, |
13 |
| - filename: 'tmp.js', |
14 |
| - }, |
15 |
| - mode: 'development', |
16 |
| - }, |
17 |
| - (err, stats) => { |
18 |
| - if (err) { |
19 |
| - console.error(err.stack || err); |
20 |
| - if (err.details) { |
21 |
| - console.error(err.details); |
22 |
| - } |
23 |
| - return; |
24 |
| - } |
25 |
| - |
26 |
| - const info = stats.toJson(); |
27 |
| - |
28 |
| - if (stats.hasErrors()) { |
29 |
| - console.error(info.errors); |
30 |
| - process.exit(1); |
31 |
| - } |
32 |
| - |
33 |
| - if (stats.hasWarnings()) { |
34 |
| - console.warn(info.warnings); |
35 |
| - process.exit(1); |
36 |
| - } |
37 |
| - |
38 |
| - runTests(); |
39 |
| - }, |
40 |
| -); |
41 |
| - |
42 |
| -function runTests() { |
43 |
| - const bundlePath = path.join(__dirname, 'tmp.js'); |
44 |
| - const { window } = new JSDOM('', { runScripts: 'dangerously' }); |
45 |
| - |
46 |
| - window.onerror = function () { |
47 |
| - console.error('ERROR thrown in manual test:'); |
48 |
| - console.error(arguments); |
49 |
| - console.error('------------------'); |
50 |
| - process.exit(1); |
51 |
| - }; |
52 |
| - |
53 |
| - const myLibrary = fs.readFileSync(bundlePath, { encoding: 'utf-8' }); |
54 |
| - |
55 |
| - if (myLibrary.indexOf('tslib_1__default') !== -1) { |
56 |
| - console.log('"tslib_1__default" reappeared...'); |
57 |
| - process.exit(1); |
58 |
| - } |
59 |
| - |
60 |
| - const scriptEl = window.document.createElement('script'); |
61 |
| - scriptEl.textContent = myLibrary; |
62 |
| - window.document.body.appendChild(scriptEl); |
63 |
| - |
64 |
| - // Testing https://github.com/getsentry/sentry-javascript/issues/2043 |
65 |
| - const scriptEl2 = window.document.createElement('script'); |
66 |
| - scriptEl2.textContent = myLibrary; |
67 |
| - window.document.body.appendChild(scriptEl2); |
68 |
| - // ------------------------------------------------------------------ |
69 |
| -} |
| 1 | +/* eslint-disable no-console */ |
| 2 | +const fs = require('fs'); |
| 3 | +const path = require('path'); |
| 4 | + |
| 5 | +const webpack = require('webpack'); |
| 6 | +const { JSDOM } = require('jsdom'); |
| 7 | + |
| 8 | +webpack( |
| 9 | + { |
| 10 | + entry: path.join(__dirname, 'test-code.js'), |
| 11 | + output: { |
| 12 | + path: __dirname, |
| 13 | + filename: 'tmp.js', |
| 14 | + }, |
| 15 | + mode: 'development', |
| 16 | + }, |
| 17 | + (err, stats) => { |
| 18 | + if (err) { |
| 19 | + console.error(err.stack || err); |
| 20 | + if (err.details) { |
| 21 | + console.error(err.details); |
| 22 | + } |
| 23 | + return; |
| 24 | + } |
| 25 | + |
| 26 | + const info = stats.toJson(); |
| 27 | + |
| 28 | + if (stats.hasErrors()) { |
| 29 | + console.error(info.errors); |
| 30 | + process.exit(1); |
| 31 | + } |
| 32 | + |
| 33 | + if (stats.hasWarnings()) { |
| 34 | + console.warn(info.warnings); |
| 35 | + process.exit(1); |
| 36 | + } |
| 37 | + |
| 38 | + runTests(); |
| 39 | + }, |
| 40 | +); |
| 41 | + |
| 42 | +function runTests() { |
| 43 | + const bundlePath = path.join(__dirname, 'tmp.js'); |
| 44 | + const { window } = new JSDOM('', { runScripts: 'dangerously' }); |
| 45 | + |
| 46 | + window.onerror = function () { |
| 47 | + console.error('ERROR thrown in manual test:'); |
| 48 | + console.error(arguments); |
| 49 | + console.error('------------------'); |
| 50 | + process.exit(1); |
| 51 | + }; |
| 52 | + |
| 53 | + const myLibrary = fs.readFileSync(bundlePath, { encoding: 'utf-8' }); |
| 54 | + |
| 55 | + if (myLibrary.indexOf('tslib_1__default') !== -1) { |
| 56 | + console.log('"tslib_1__default" reappeared...'); |
| 57 | + process.exit(1); |
| 58 | + } |
| 59 | + |
| 60 | + const scriptEl = window.document.createElement('script'); |
| 61 | + scriptEl.textContent = myLibrary; |
| 62 | + window.document.body.appendChild(scriptEl); |
| 63 | + |
| 64 | + // Testing https://github.com/getsentry/sentry-javascript/issues/2043 |
| 65 | + const scriptEl2 = window.document.createElement('script'); |
| 66 | + scriptEl2.textContent = myLibrary; |
| 67 | + window.document.body.appendChild(scriptEl2); |
| 68 | + // ------------------------------------------------------------------ |
| 69 | +} |
0 commit comments