A big commit with a bunch of node modules so I could run puppeteer for Walmart. Added some todos and Headway's templates.
This commit is contained in:
49
Scripts/node_modules/cosmiconfig/dist/loaders.js
generated
vendored
49
Scripts/node_modules/cosmiconfig/dist/loaders.js
generated
vendored
@ -23,7 +23,19 @@ const loadJs = async function loadJs(filepath) {
|
||||
return (await import(href)).default;
|
||||
}
|
||||
catch (error) {
|
||||
return (0, exports.loadJsSync)(filepath, '');
|
||||
try {
|
||||
return (0, exports.loadJsSync)(filepath, '');
|
||||
}
|
||||
catch (requireError) {
|
||||
if (requireError.code === 'ERR_REQUIRE_ESM' ||
|
||||
(requireError instanceof SyntaxError &&
|
||||
requireError
|
||||
.toString()
|
||||
.includes('Cannot use import statement outside a module'))) {
|
||||
throw error;
|
||||
}
|
||||
throw requireError;
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.loadJs = loadJs;
|
||||
@ -91,23 +103,26 @@ const loadTs = async function loadTs(filepath, content) {
|
||||
typescript = (await import('typescript')).default;
|
||||
}
|
||||
const compiledFilepath = `${filepath.slice(0, -2)}mjs`;
|
||||
let transpiledContent;
|
||||
try {
|
||||
const config = resolveTsConfig(path_1.default.dirname(filepath)) ?? {};
|
||||
config.compilerOptions = {
|
||||
...config.compilerOptions,
|
||||
module: typescript.ModuleKind.ES2022,
|
||||
moduleResolution: typescript.ModuleResolutionKind.Bundler,
|
||||
target: typescript.ScriptTarget.ES2022,
|
||||
noEmit: false,
|
||||
};
|
||||
content = typescript.transpileModule(content, config).outputText;
|
||||
await (0, promises_1.writeFile)(compiledFilepath, content);
|
||||
const { href } = (0, url_1.pathToFileURL)(compiledFilepath);
|
||||
return (await import(href)).default;
|
||||
}
|
||||
catch (error) {
|
||||
error.message = `TypeScript Error in ${filepath}:\n${error.message}`;
|
||||
throw error;
|
||||
try {
|
||||
const config = resolveTsConfig(path_1.default.dirname(filepath)) ?? {};
|
||||
config.compilerOptions = {
|
||||
...config.compilerOptions,
|
||||
module: typescript.ModuleKind.ES2022,
|
||||
moduleResolution: typescript.ModuleResolutionKind.Bundler,
|
||||
target: typescript.ScriptTarget.ES2022,
|
||||
noEmit: false,
|
||||
};
|
||||
transpiledContent = typescript.transpileModule(content, config).outputText;
|
||||
await (0, promises_1.writeFile)(compiledFilepath, transpiledContent);
|
||||
}
|
||||
catch (error) {
|
||||
error.message = `TypeScript Error in ${filepath}:\n${error.message}`;
|
||||
throw error;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/return-await
|
||||
return await (0, exports.loadJs)(compiledFilepath, transpiledContent);
|
||||
}
|
||||
finally {
|
||||
if ((0, fs_1.existsSync)(compiledFilepath)) {
|
||||
|
||||
Reference in New Issue
Block a user