MCPcopy Index your code
hub / github.com/R-js/libRmath.js / init

Function init

scripts/build.ts:158–201  ·  view source on GitHub ↗
(targetDir: string, commenjsDir: string, esmDir: string, roots: string[])

Source from the content-addressed store, hash-verified

156}
157
158function init(targetDir: string, commenjsDir: string, esmDir: string, roots: string[]) {
159 removeSafeDir(targetDir);
160 mkdirSync(commenjsDir, { recursive: true });
161 mkdirSync(esmDir, { recursive: true });
162 // Read the TypeScript config file.
163 const { config } = ts.readConfigFile('tsconfig.json', (fileName) => readFileSync(fileName).toString());
164
165 const sourceDir = join('src');
166
167 const compile = createCompiler(config, sourceDir);
168
169 compile(
170 roots,
171 esmDir,
172 {
173 module: ts.ModuleKind.ES2020,
174 moduleResolution: ts.ModuleResolutionKind.NodeJs,
175 declaration: true,
176 declarationDir: './types', // this becomes ./dist/types
177 declarationMap: false,
178 removeComments: true,
179 sourceMap: false,
180 importHelpers: false,
181 outDir: undefined
182 },
183 ['.ts']
184 );
185
186 compile(
187 roots,
188 commenjsDir,
189 {
190 module: ts.ModuleKind.CommonJS,
191 moduleResolution: ts.ModuleResolutionKind.NodeJs,
192 declaration: false,
193 outDir: undefined, // this is a must!
194 declarationMap: false,
195 removeComments: true,
196 sourceMap: false,
197 importHelpers: false // commonjs sometimes needs some extra code to create analogs for esm constructs (example export * from 'xyz)
198 },
199 ['.ts']
200 );
201}
202
203init('./dist', './dist/commonjs', './dist/esm', ['./src/index.ts']);

Callers 1

build.tsFile · 0.70

Calls 2

removeSafeDirFunction · 0.85
createCompilerFunction · 0.85

Tested by

no test coverage detected