Introspecting ECMAScript 6 module members in a web browser console

554 views Asked by At

I am trying out some third party JavaScript.

Let's say I import an ES6 module in a Chrome dev tools console:

import('https://unpkg.com/web3/dist/web3.js').then(module => console.log(module));

It gives me:

Module {Symbol(Symbol.toStringTag): "Module"}
Symbol(Symbol.toStringTag): "Module"

Is there a way for me to introspect the module contents from the JavaScript console, so that I can see what exports the module offers me to import and use?

1

There are 1 answers

0
Mikko Ohtamaa On

The syntax is correct

import("https://unpkg.com/es-react").then(module => console.log(module));

However, the loaded module must explicitly support ECMAScript 6 module exports, so that the web browser will find any members.

Module {…}
Children: (...)
Component: (...)
Fragment: (...)
Profiler: (...)
PropTypes: (...)
PureComponent: (...)
React: (...)
ReactDOM: (...)
StrictMode: (...)
Suspense: (...)
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: (...)
cloneElement: (...)
createContext: (...)
createElement: (...)
createFactory: (...)
createRef: (...)
default: (...)
forwardRef: (...)
isValidElement: (...)
lazy: (...)
memo: (...)
useCallback: (...)
useContext: (...)
useDebugValue: (...)
useEffect: (...)
useImperativeHandle: (...)
useLayoutEffect: (...)
useMemo: (...)
useReducer: (...)
useRef: (...)
useState: (...)
version: (...)