Nicolò Ribaudo d04842a700
Avoid using CJS globals in internal source files (#12963)
* Lint against CJS globals in modules

* Use `import.meta.url` instead of `__filename` in `src` files

* Prepare fixtures runner for `import.meta.url`

* Use `import.meta.url` instead of `__filename` in `test/index` files

* Remove `__dirname` from remaining test files

dirname

* Avoid using `module` in `src` files

* Avoid using `require` in `src` files

* Avoid using `require` in `test` files

* Update `@types/node`

* Compile dynamic import in `@babel/node`

* Fix windows

* Use `@babel/plugin-proposal-dynamic-import` from npm
2021-03-05 19:55:36 +01:00

25 lines
683 B
JavaScript

import browserify from "browserify";
import path from "path";
import vm from "vm";
import { fileURLToPath } from "url";
describe("browserify", function () {
it("@babel/register may be used without breaking browserify", function (done) {
const bundler = browserify(
path.join(
path.dirname(fileURLToPath(import.meta.url)),
"fixtures/browserify/register.js",
),
);
bundler.bundle(function (err, bundle) {
if (err) return done(err);
expect(bundle.length).toBeTruthy();
// ensure that the code runs without throwing an exception
vm.runInNewContext("var global = this;\n" + bundle, {});
done();
});
});
});