Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ function getPlugins(
globalName,
filename,
moduleType,
bundle.wrapWithModuleBoundaries
bundle.wrapWithModuleBoundaries,
bundle.wrapWithNodeDevGuard
);
},
},
Expand Down
5 changes: 4 additions & 1 deletion scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1235,12 +1235,15 @@ const bundles = [
// currently required in order for the package to be copied over correctly.
// So, it would be worth improving that flow.
name: 'eslint-plugin-react-hooks',
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD, CJS_DTS],
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, CJS_DTS],
moduleType: ISOMORPHIC,
entry: 'eslint-plugin-react-hooks/src/index.ts',
global: 'ESLintPluginReactHooks',
minifyWithProdErrorCodes: false,
wrapWithModuleBoundaries: false,
// This is a Node.js build tool (ESLint plugin), not a www runtime bundle.
// Use process.env.NODE_ENV guard instead of __DEV__ for the dev wrapper.
wrapWithNodeDevGuard: true,
preferBuiltins: true,
externals: [
'@babel/core',
Expand Down
11 changes: 9 additions & 2 deletions scripts/rollup/wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ function wrapWithTopLevelDefinitions(
globalName,
filename,
moduleType,
wrapWithModuleBoundaries
wrapWithModuleBoundaries,
wrapWithNodeDevGuard
) {
if (wrapWithModuleBoundaries) {
switch (bundleType) {
Expand Down Expand Up @@ -553,8 +554,14 @@ function wrapWithTopLevelDefinitions(
return wrapper(source, globalName, filename, moduleType);
}

// Node.js build tools (e.g. ESLint plugins) use process.env.NODE_ENV instead
// of __DEV__ even when building for FB_WWW, since they run in Node.js where
// __DEV__ is not defined.
const effectiveBundleType =
wrapWithNodeDevGuard && bundleType === FB_WWW_DEV ? NODE_DEV : bundleType;

// All the other packages.
const wrapper = topLevelDefinitionWrappers[bundleType];
const wrapper = topLevelDefinitionWrappers[effectiveBundleType];
if (typeof wrapper !== 'function') {
throw new Error(`Unsupported build type: ${bundleType}.`);
}
Expand Down
Loading