Created
August 19, 2020 02:25
-
-
Save kumavis/b58078cbe935a2bd3e9313d133c7d49a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { builtinModules: builtinPackages } = require('module') | |
// [email protected] | |
const { createModuleInspector } = require('lavamoat-core') | |
const inspector = createModuleInspector({ | |
// used to see if this imports builtins | |
isBuiltin: (name) => builtinPackages.includes(name), | |
// adds some notes on ses compat, etc | |
includeDebugInfo: true, | |
}) | |
inspector.inspectModule({ | |
// unique name, may be same as filename | |
specifier: 'string', | |
// filename | |
file: 'node_modules/xyz/index.js' | |
// does not include version | |
packageName: '', | |
// { js, builtin, native } | |
type: 'js', | |
// the code, no module initializer wrapper | |
content: 'module.exports = 42', | |
// key is requestedName, value is specifier | |
importMap: { | |
'./util': 'node_modules/xyz/util.js' | |
}, | |
// (optional) pregenerated babel ast | |
ast: undefined, | |
}) | |
const config = inspector.generateConfig() | |
// package policy is here | |
// config.resouces[packageName] | |
// debug info is here | |
// config.debugInfo[moduleSpecifier] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment