Add .gitignore to exclude all node packages and lock files
This commit is contained in:
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import type webpack from 'webpack';
|
||||
import type { LoaderOptions } from './interfaces';
|
||||
declare function ESBuildLoader(this: webpack.LoaderContext<LoaderOptions>, source: string): Promise<void>;
|
||||
export default ESBuildLoader;
|
||||
Generated
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const esbuild_1 = require("esbuild");
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const isTsExtensionPtrn = /\.ts$/i;
|
||||
const isTypescriptInstalled = () => {
|
||||
try {
|
||||
require.resolve('typescript');
|
||||
return true;
|
||||
}
|
||||
catch (_a) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
async function ESBuildLoader(source) {
|
||||
var _a, _b, _c;
|
||||
const done = this.async();
|
||||
const options = this.getOptions();
|
||||
const { implementation, remotionRoot, ...esbuildTransformOptions } = options;
|
||||
const tsConfigPath = node_path_1.default.join(remotionRoot, 'tsconfig.json');
|
||||
if (implementation && typeof implementation.transform !== 'function') {
|
||||
done(new TypeError(`esbuild-loader: options.implementation.transform must be an ESBuild transform function. Received ${typeof implementation.transform}`));
|
||||
return;
|
||||
}
|
||||
const transform = (_a = implementation === null || implementation === void 0 ? void 0 : implementation.transform) !== null && _a !== void 0 ? _a : esbuild_1.transform;
|
||||
const transformOptions = {
|
||||
...esbuildTransformOptions,
|
||||
target: (_b = options.target) !== null && _b !== void 0 ? _b : 'es2015',
|
||||
loader: (_c = options.loader) !== null && _c !== void 0 ? _c : 'js',
|
||||
sourcemap: this.sourceMap,
|
||||
sourcefile: this.resourcePath,
|
||||
};
|
||||
if (!('tsconfigRaw' in transformOptions) && isTypescriptInstalled()) {
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||
const typescript = require('typescript');
|
||||
const tsConfig = typescript.readConfigFile(tsConfigPath, typescript.sys.readFile);
|
||||
transformOptions.tsconfigRaw = tsConfig.config;
|
||||
}
|
||||
// https://github.com/privatenumber/esbuild-loader/pull/107
|
||||
if (transformOptions.loader === 'tsx' &&
|
||||
isTsExtensionPtrn.test(this.resourcePath)) {
|
||||
transformOptions.loader = 'ts';
|
||||
}
|
||||
try {
|
||||
const { code, map } = await transform(source, transformOptions);
|
||||
done(null, code, map && JSON.parse(map));
|
||||
}
|
||||
catch (error) {
|
||||
done(error);
|
||||
}
|
||||
}
|
||||
exports.default = ESBuildLoader;
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
import type { transform, TransformOptions } from 'esbuild';
|
||||
type Implementation = {
|
||||
transform: typeof transform;
|
||||
};
|
||||
type Except<ObjectType, Properties> = {
|
||||
[Key in keyof ObjectType as Key extends Properties ? never : Key]: ObjectType[Key];
|
||||
};
|
||||
export type LoaderOptions = Except<TransformOptions, 'sourcemap' | 'sourcefile'> & {
|
||||
implementation: Implementation;
|
||||
remotionRoot: string;
|
||||
};
|
||||
export {};
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
Reference in New Issue
Block a user