Skip to content

Commit

Permalink
Don't use Node.js functions when bundling for the browser (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Feb 25, 2021
1 parent 4fe2e83 commit 783ccd5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/babel-helper-define-polyfill-provider/package.json
Expand Up @@ -16,7 +16,8 @@
},
"main": "lib/index.js",
"browser": {
"./lib/config/loader.js": "./lib/config/loader-browser.js"
"./lib/node/dependencies.js": "./lib/browser/dependencies.js",
"./src/node/dependencies.js": "./src/browser/dependencies.js"
},
"dependencies": {
"@babel/helper-compilation-targets": "^7.13.0",
Expand Down
@@ -0,0 +1,24 @@
// @flow

export function resolve(
dirname: string,
moduleName: string,
absoluteImports: boolean | string,
): string {
if (absoluteImports === false) return moduleName;

throw new Error(
`"absoluteImports" is not supported in bundles prepared for the browser.`,
);
}

// eslint-disable-next-line no-unused-vars
export function has(basedir: string, name: string) {
return true;
}

// eslint-disable-next-line no-unused-vars
export function logMissing(missingDeps: Set<string>) {}

// eslint-disable-next-line no-unused-vars
export function laterLogMissing(missingDeps: Set<string>) {}
Expand Up @@ -30,7 +30,7 @@ import type {
} from "./types";

import * as v from "./visitors";
import * as deps from "./dependencies";
import * as deps from "./node/dependencies";

import createMetaResolver from "./meta-resolver";

Expand Down

0 comments on commit 783ccd5

Please sign in to comment.