UNPKG

telefunc

Version:

Remote functions. Instead of API.

20 lines (19 loc) 721 B
export { getInfo }; export { getRoot }; import { assert } from '../utils.js'; function getInfo(loader) { assert(loader._compiler.name === 'client' || loader._compiler.name === 'server'); const isClientSide = loader._compiler.name !== 'server'; const root = getRoot(loader._compiler); assert(typeof loader.resource === 'string'); const id = loader.resource; assert(id.includes('.telefunc.')); assert(loader.mode === 'production' || loader.mode === 'development'); const isDev = loader.mode === 'development'; return { id, root, isClientSide, isDev }; } function getRoot(compiler) { assert(typeof compiler.context === 'string'); const root = compiler.context; return root; }