Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Sep 18, 2023
1 parent ace7ee1 commit 691d725
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/babel-plugin-proposal-import-defer/src/index.ts
Expand Up @@ -84,7 +84,7 @@ export default declare(api => {
// import "a"
// we have the correct evaluation order

const eagerImports = new Map();
const eagerImports = new Set();

for (const child of path.get("body")) {
if (
Expand All @@ -94,7 +94,7 @@ export default declare(api => {
) {
const specifier = child.node.source!.value;
if (!eagerImports.has(specifier)) {
eagerImports.set(specifier, child);
eagerImports.add(specifier);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/babel-plugin-transform-modules-commonjs/src/hooks.ts
Expand Up @@ -6,10 +6,15 @@ const commonJSHooksKey =

type SourceMetadata = Parameters<typeof isSideEffectImport>[0];

// A hook exposes a set of function that can customize how `require()` calls and
// references to the imported bindings are handled. These functions can either
// return a result, or return `null` to delegate to the next hook.
export interface CommonJSHook {
name: string;
version: string;
wrapReference?(ref: t.Expression, payload: unknown): t.CallExpression | null;
// Optionally wrap a `require` call. If this function returns `false`, the
// `require` call is removed from the generated code.
buildRequireWrapper?(
name: string,
init: t.Expression,
Expand Down

0 comments on commit 691d725

Please sign in to comment.