nezuhub's picture
download
raw
3.79 kB
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadConfigFile = exports.executeConfigFile = exports.prepareConfigFile = void 0;
const node_fs_1 = __importDefault(require("node:fs"));
const node_path_1 = __importDefault(require("node:path"));
const node_worker_threads_1 = require("node:worker_threads");
const bundler_1 = require("@remotion/bundler");
const client_1 = require("@remotion/renderer/client");
const log_1 = require("./log");
const parsed_cli_1 = require("./parsed-cli");
const prepareConfigFile = async (remotionRoot, configFileName, isJavascript) => {
const resolved = node_path_1.default.resolve(remotionRoot, configFileName);
const tsconfigJson = node_path_1.default.join(remotionRoot, 'tsconfig.json');
if (!isJavascript && !node_fs_1.default.existsSync(tsconfigJson)) {
throw new Error(`Could not find a tsconfig.json file in your project. Did you delete it? Create a tsconfig.json in the root of your project. Copy the default file from https://github.com/remotion-dev/template-helloworld/blob/main/tsconfig.json. The root directory is: ${remotionRoot}`);
}
const virtualOutfile = 'bundle.js';
const result = await bundler_1.BundlerInternals.esbuild.build({
platform: 'node',
target: 'node16',
bundle: true,
entryPoints: [resolved],
tsconfig: isJavascript ? undefined : tsconfigJson,
absWorkingDir: remotionRoot,
outfile: virtualOutfile,
write: false,
packages: 'external',
});
if (result.errors.length > 0) {
throw new Error(`Error in remotion.config.ts file: ${result.errors
.map((error) => error.text)
.join('\n')}`);
}
const firstOutfile = result.outputFiles[0];
if (!firstOutfile) {
throw new Error('No output files found in the config file.');
}
const code = new TextDecoder().decode(firstOutfile.contents);
return { code, remotionRoot, resolved };
};
exports.prepareConfigFile = prepareConfigFile;
const executeConfigFile = ({ code, remotionRoot }) => {
let str = code;
const currentCwd = process.cwd();
// The config file is always executed from the Remotion root, if `process.cwd()` is being used. We cannot enforce this in worker threads used for testing
if (node_worker_threads_1.isMainThread) {
process.chdir(remotionRoot);
}
if (process.env.PATCH_BUN_DEVELOPMENT) {
str = str.replace('@remotion/cli/config', './config');
}
try {
// Execute the contents of the config file
// eslint-disable-next-line no-eval
eval(str);
if ('webcontainer' in process.versions &&
client_1.BrowserSafeApis.options.rspackOption.getConfigValue() === true) {
client_1.BrowserSafeApis.options.rspackOption.setConfig(false);
log_1.Log.warn({
indent: false,
logLevel: client_1.BrowserSafeApis.options.logLevelOption.getValue({
commandLine: parsed_cli_1.parsedCli,
}).value,
}, 'Rspack is currently disabled in WebContainers. Falling back to Webpack.');
}
}
finally {
if (node_worker_threads_1.isMainThread) {
process.chdir(currentCwd);
}
}
};
exports.executeConfigFile = executeConfigFile;
const loadConfigFile = async (remotionRoot, configFileName, isJavascript) => {
const prepared = await (0, exports.prepareConfigFile)(remotionRoot, configFileName, isJavascript);
(0, exports.executeConfigFile)(prepared);
return prepared;
};
exports.loadConfigFile = loadConfigFile;

Xet Storage Details

Size:
3.79 kB
·
Xet hash:
5d70892be79c84c452ceefa0c93b5580156a5a5a22dba9a857060e5e775b9e1e

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.