/
opt
/
canhelp
/
node_modules
/
next
/
dist
/
build
/
babel
/
plugins
/
/opt/canhelp/node_modules/next/dist/build/babel/plugins
mkdir
upload
Name
Size
Mode
Actions
amp-attributes.d.ts
122
0644
edit
dl
rm
amp-attributes.js
1043
0644
edit
dl
rm
amp-attributes.js.map
1533
0644
edit
dl
rm
commonjs.d.ts
135
0644
edit
dl
rm
commonjs.js
1420
0644
edit
dl
rm
commonjs.js.map
1860
0644
edit
dl
rm
jsx-pragma.d.ts
230
0644
edit
dl
rm
jsx-pragma.js
3703
0644
edit
dl
rm
jsx-pragma.js.map
6423
0644
edit
dl
rm
next-font-unsupported.d.ts
142
0644
edit
dl
rm
next-font-unsupported.js
1442
0644
edit
dl
rm
next-font-unsupported.js.map
1793
0644
edit
dl
rm
next-page-config.d.ts
234
0644
edit
dl
rm
next-page-config.js
9039
0644
edit
dl
rm
next-page-config.js.map
12458
0644
edit
dl
rm
next-page-disallow-re-export-all-exports.d.ts
142
0644
edit
dl
rm
next-page-disallow-re-export-all-exports.js
1183
0644
edit
dl
rm
next-page-disallow-re-export-all-exports.js.map
1493
0644
edit
dl
rm
next-ssg-transform.d.ts
634
0644
edit
dl
rm
next-ssg-transform.js
16745
0644
edit
dl
rm
next-ssg-transform.js.map
24863
0644
edit
dl
rm
optimize-hook-destructuring.d.ts
230
0644
edit
dl
rm
optimize-hook-destructuring.js
2486
0644
edit
dl
rm
optimize-hook-destructuring.js.map
4629
0644
edit
dl
rm
react-loadable-plugin.d.ts
1327
0644
edit
dl
rm
react-loadable-plugin.js
7964
0644
edit
dl
rm
react-loadable-plugin.js.map
12650
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/next/dist/build/babel/plugins/optimize-hook-destructuring.js
(2486B)
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "default", { enumerable: true, get: function() { return _default; } }); // matches any hook-like (the default) const isHook = /^use[A-Z]/; // matches only built-in hooks provided by React et al const isBuiltInHook = /^use(Callback|Context|DebugValue|Effect|ImperativeHandle|LayoutEffect|Memo|Reducer|Ref|State)$/; function _default({ types: t }) { const visitor = { CallExpression (path, state) { const onlyBuiltIns = state.opts.onlyBuiltIns; // if specified, options.lib is a list of libraries that provide hook functions const libs = state.opts.lib && (state.opts.lib === true ? [ 'react', 'preact/hooks' ] : [].concat(state.opts.lib)); // skip function calls that are not the init of a variable declaration: if (!t.isVariableDeclarator(path.parent)) return; // skip function calls where the return value is not Array-destructured: if (!t.isArrayPattern(path.parent.id)) return; // name of the (hook) function being called: const hookName = path.node.callee.name; if (libs) { const binding = path.scope.getBinding(hookName); // not an import if (!binding || binding.kind !== 'module') return; const specifier = binding.path.parent.source.value; // not a match if (!libs.some((lib)=>lib === specifier)) return; } // only match function calls with names that look like a hook if (!(onlyBuiltIns ? isBuiltInHook : isHook).test(hookName)) return; path.parent.id = t.objectPattern(path.parent.id.elements.reduce((patterns, element, i)=>{ if (element === null) { return patterns; } return patterns.concat(t.objectProperty(t.numericLiteral(i), // TODO: fix this element)); }, [])); } }; return { name: 'optimize-hook-destructuring', visitor: { // this is a workaround to run before preset-env destroys destructured assignments Program (path, state) { path.traverse(visitor, state); } } }; } //# sourceMappingURL=optimize-hook-destructuring.js.map
Save
cmd:
run