MCPcopy Index your code
hub / github.com/bytecodealliance/ComponentizeJS / componentize

Function componentize

src/componentize.js:66–439  ·  view source on GitHub ↗
(
  opts,
  _deprecatedWitWorldOrOpts = undefined,
  _deprecatedOpts = undefined,
)

Source from the content-addressed store, hash-verified

64export const DEFAULT_FEATURES = ['stdio', 'random', 'clocks', 'http', 'fetch-event'];
65
66export async function componentize(
67 opts,
68 _deprecatedWitWorldOrOpts = undefined,
69 _deprecatedOpts = undefined,
70) {
71 let useOriginalSourceFile = true;
72 let jsSource;
73
74 // Handle the two old signatures
75 // (jsSource, witWorld, opts?)
76 // (jsSource, opts)
77 if (typeof opts === 'string') {
78 jsSource = opts;
79 useOriginalSourceFile = false;
80 if (typeof _deprecatedWitWorldOrOpts === 'string') {
81 opts = _deprecatedOpts || {};
82 opts.witWorld = _deprecatedWitWorldOrOpts;
83 } else {
84 if (typeof _deprecatedWitWorldOrOpts !== 'object') {
85 throw new Error(
86 `componentize: second argument must be an object or a string, but is ${typeof _deprecatedWitWorldOrOpts}`,
87 );
88 }
89 opts = _deprecatedWitWorldOrOpts;
90 }
91 }
92
93 // Prepare a working directory for use during componentization
94 const { sourcesDir, baseDir: workDir } = await prepWorkDir();
95
96 let {
97 sourceName = 'source.js',
98 sourcePath = maybeWindowsPath(join(sourcesDir, sourceName)),
99 preview2Adapter = preview1AdapterReactorPath(),
100 witPath,
101 witWorld,
102 worldName,
103 disableFeatures = [],
104 enableFeatures = [],
105
106 debug = { ...DEFAULT_DEBUG_SETTINGS },
107 debugBuild = false,
108 debugBindings = false,
109 enableWizerLogging = false,
110
111 runtimeArgs,
112
113 aotCache = DEFAULT_AOT_CACHE,
114 } = opts;
115
116 debugBindings = debugBindings || debug?.bindings;
117 debugBuild = debugBuild || debug?.build;
118 enableWizerLogging = enableWizerLogging || debug?.enableWizerLogging;
119
120 // Determine the path to the StarlingMonkey binary
121 const engine = getEnginePath(opts);
122
123 // Determine the default features that should be included

Callers 5

componentizeCmdFunction · 0.90
setupComponentFunction · 0.85
builtins.jsFile · 0.85
bindings.jsFile · 0.85
componentize.jsFile · 0.85

Calls 11

maybeWindowsPathFunction · 0.90
prepWorkDirFunction · 0.85
getEnginePathFunction · 0.85
isNumericFunction · 0.85
defaultMinStackSizeFunction · 0.85
parseWizerStderrFunction · 0.85
initWasmFunction · 0.85
handleCheckInitOutputFunction · 0.85
check_initFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected