| 1 |
import browserify from "browserify"; |
| 2 |
import path from "path"; |
| 3 |
import vm from "vm"; |
| 4 |
import { fileURLToPath } from "url"; |
| 5 |
|
| 6 |
describe("browserify", function () { |
| 7 |
it("@babel/register may be used without breaking browserify", function () { |
| 8 |
const bundler = browserify( |
| 9 |
path.join( |
| 10 |
path.dirname(fileURLToPath(import.meta.url)), |
| 11 |
"fixtures/browserify/register.js", |
| 12 |
), |
| 13 |
); |
| 14 |
return new Promise((resolve, reject) => { |
| 15 |
bundler.bundle(function (err, bundle) { |
| 16 |
if (err) return reject(err); |
| 17 |
expect(bundle.length).toBeTruthy(); |
| 18 |
|
| 19 |
|
| 20 |
vm.runInNewContext("var global = this;\n" + bundle, {}); |
| 21 |
resolve(); |
| 22 |
}); |
| 23 |
}); |
| 24 |
}); |
| 25 |
}); |