@remotion/bundler 3.2.15 → 3.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { WebpackOverrideFn } from 'remotion';
2
2
  import webpack from 'webpack';
3
- export declare type BundleOptions = {
3
+ export declare type LegacyBundleOptions = {
4
4
  webpackOverride?: WebpackOverrideFn;
5
5
  outDir?: string;
6
6
  enableCaching?: boolean;
@@ -8,11 +8,21 @@ export declare type BundleOptions = {
8
8
  rootDir?: string;
9
9
  publicDir?: string | null;
10
10
  };
11
- export declare const getConfig: ({ entryPoint, outDir, resolvedRemotionRoot, onProgressUpdate, options, }: {
11
+ export declare const getConfig: ({ entryPoint, outDir, resolvedRemotionRoot, onProgress, options, }: {
12
12
  outDir: string;
13
13
  entryPoint: string;
14
14
  resolvedRemotionRoot: string;
15
- onProgressUpdate?: ((progress: number) => void) | undefined;
16
- options?: BundleOptions | undefined;
15
+ onProgress?: ((progress: number) => void) | undefined;
16
+ options?: LegacyBundleOptions | undefined;
17
17
  }) => [string, webpack.Configuration];
18
- export declare const bundle: (entryPoint: string, onProgressUpdate?: ((progress: number) => void) | undefined, options?: BundleOptions) => Promise<string>;
18
+ export declare type BundleOptions = {
19
+ entryPoint: string;
20
+ onProgress?: (progress: number) => void;
21
+ } & LegacyBundleOptions;
22
+ declare type Arguments = [options: BundleOptions] | [
23
+ entryPoint: string,
24
+ onProgress?: (progress: number) => void,
25
+ options?: LegacyBundleOptions
26
+ ];
27
+ export declare function bundle(...args: Arguments): Promise<string>;
28
+ export {};
package/dist/bundle.js CHANGED
@@ -13,7 +13,6 @@ const worker_threads_1 = require("worker_threads");
13
13
  const copy_dir_1 = require("./copy-dir");
14
14
  const index_html_1 = require("./index-html");
15
15
  const webpack_config_1 = require("./webpack-config");
16
- const entry = require.resolve('./renderEntry');
17
16
  const promisified = (0, util_1.promisify)(webpack_1.default);
18
17
  const prepareOutDir = async (specified) => {
19
18
  if (specified) {
@@ -34,15 +33,16 @@ const trimTrailingSlash = (p) => {
34
33
  }
35
34
  return p;
36
35
  };
37
- const getConfig = ({ entryPoint, outDir, resolvedRemotionRoot, onProgressUpdate, options, }) => {
36
+ const getConfig = ({ entryPoint, outDir, resolvedRemotionRoot, onProgress, options, }) => {
38
37
  var _a, _b;
38
+ const entry = require.resolve('./renderEntry');
39
39
  return (0, webpack_config_1.webpackConfig)({
40
40
  entry,
41
41
  userDefinedComponent: entryPoint,
42
42
  outDir,
43
43
  environment: 'production',
44
44
  webpackOverride: (_a = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _a !== void 0 ? _a : ((f) => f),
45
- onProgressUpdate,
45
+ onProgress,
46
46
  enableCaching: (_b = options === null || options === void 0 ? void 0 : options.enableCaching) !== null && _b !== void 0 ? _b : true,
47
47
  maxTimelineTracks: 15,
48
48
  // For production, the variables are set dynamically
@@ -53,10 +53,29 @@ const getConfig = ({ entryPoint, outDir, resolvedRemotionRoot, onProgressUpdate,
53
53
  });
54
54
  };
55
55
  exports.getConfig = getConfig;
56
- const bundle = async (entryPoint, onProgressUpdate, options) => {
56
+ const convertArgumentsIntoOptions = (args) => {
57
+ var _a;
58
+ if (args.length === 0) {
59
+ throw new TypeError('bundle() was called without arguments');
60
+ }
61
+ const firstArg = args[0];
62
+ if (typeof firstArg === 'string') {
63
+ return {
64
+ entryPoint: firstArg,
65
+ onProgress: args[1],
66
+ ...((_a = args[2]) !== null && _a !== void 0 ? _a : {}),
67
+ };
68
+ }
69
+ if (typeof firstArg.entryPoint !== 'string') {
70
+ throw new TypeError('bundle() was called without the `entryPoint` option');
71
+ }
72
+ return firstArg;
73
+ };
74
+ async function bundle(...args) {
57
75
  var _a, _b, _c;
58
- const resolvedRemotionRoot = (_a = options === null || options === void 0 ? void 0 : options.rootDir) !== null && _a !== void 0 ? _a : process.cwd();
59
- const outDir = await prepareOutDir((_b = options === null || options === void 0 ? void 0 : options.outDir) !== null && _b !== void 0 ? _b : null);
76
+ const actualArgs = convertArgumentsIntoOptions(args);
77
+ const resolvedRemotionRoot = (_a = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.rootDir) !== null && _a !== void 0 ? _a : process.cwd();
78
+ const outDir = await prepareOutDir((_b = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.outDir) !== null && _b !== void 0 ? _b : null);
60
79
  // The config might use an override which might use
61
80
  // `process.cwd()`. The context should always be the Remotion root.
62
81
  // This is not supported in worker threads (used for tests)
@@ -64,11 +83,12 @@ const bundle = async (entryPoint, onProgressUpdate, options) => {
64
83
  if (worker_threads_1.isMainThread) {
65
84
  process.chdir(resolvedRemotionRoot);
66
85
  }
86
+ const { entryPoint, onProgress, ...options } = actualArgs;
67
87
  const [, config] = (0, exports.getConfig)({
68
88
  outDir,
69
89
  entryPoint,
70
90
  resolvedRemotionRoot,
71
- onProgressUpdate,
91
+ onProgress,
72
92
  options,
73
93
  });
74
94
  const output = await promisified([config]);
@@ -82,7 +102,7 @@ const bundle = async (entryPoint, onProgressUpdate, options) => {
82
102
  if (errors !== undefined && errors.length > 0) {
83
103
  throw new Error(errors[0].message + '\n' + errors[0].details);
84
104
  }
85
- const baseDir = (_c = options === null || options === void 0 ? void 0 : options.publicPath) !== null && _c !== void 0 ? _c : '/';
105
+ const baseDir = (_c = actualArgs === null || actualArgs === void 0 ? void 0 : actualArgs.publicPath) !== null && _c !== void 0 ? _c : '/';
86
106
  const staticHash = '/' +
87
107
  [trimTrailingSlash(trimLeadingSlash(baseDir)), 'public']
88
108
  .filter(Boolean)
@@ -104,5 +124,5 @@ const bundle = async (entryPoint, onProgressUpdate, options) => {
104
124
  });
105
125
  fs_1.default.writeFileSync(path_1.default.join(outDir, 'index.html'), html);
106
126
  return outDir;
107
- };
127
+ }
108
128
  exports.bundle = bundle;
package/dist/index.d.ts CHANGED
@@ -2,13 +2,13 @@ import esbuild = require('esbuild');
2
2
  import webpack = require('webpack');
3
3
  export declare const BundlerInternals: {
4
4
  esbuild: typeof esbuild;
5
- webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgressUpdate, enableCaching, envVariables, maxTimelineTracks, entryPoints, remotionRoot, keyboardShortcutsEnabled, }: {
5
+ webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgress, enableCaching, envVariables, maxTimelineTracks, entryPoints, remotionRoot, keyboardShortcutsEnabled, }: {
6
6
  entry: string;
7
7
  userDefinedComponent: string;
8
8
  outDir: string;
9
9
  environment: "development" | "production";
10
10
  webpackOverride: import("remotion/dist/internals").WebpackOverrideFn;
11
- onProgressUpdate?: ((f: number) => void) | undefined;
11
+ onProgress?: ((f: number) => void) | undefined;
12
12
  enableCaching?: boolean | undefined;
13
13
  envVariables: Record<string, string>;
14
14
  maxTimelineTracks: number;
@@ -26,14 +26,14 @@ export declare const BundlerInternals: {
26
26
  }) => string;
27
27
  cacheExists: (remotionRoot: string, environment: "development" | "production", hash: string) => "exists" | "other-exists" | "does-not-exist";
28
28
  clearCache: (remotionRoot: string) => Promise<void>;
29
- getConfig: ({ entryPoint, outDir, resolvedRemotionRoot, onProgressUpdate, options, }: {
29
+ getConfig: ({ entryPoint, outDir, resolvedRemotionRoot, onProgress, options, }: {
30
30
  outDir: string;
31
31
  entryPoint: string;
32
32
  resolvedRemotionRoot: string;
33
- onProgressUpdate?: ((progress: number) => void) | undefined;
34
- options?: import("./bundle").BundleOptions | undefined;
33
+ onProgress?: ((progress: number) => void) | undefined;
34
+ options?: import("./bundle").LegacyBundleOptions | undefined;
35
35
  }) => [string, webpack.Configuration];
36
36
  };
37
- export { bundle, BundleOptions } from './bundle';
37
+ export { bundle, BundleOptions, LegacyBundleOptions } from './bundle';
38
38
  export { webpack };
39
39
  export declare type WebpackConfiguration = webpack.Configuration;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const bundle_1 = require("../bundle");
5
+ (0, vitest_1.test)('Should reject bad bundle options', () => {
6
+ // @ts-expect-error
7
+ (0, vitest_1.expect)(() => (0, bundle_1.bundle)()).rejects.toThrow(/bundle\(\) was called without arguments/);
8
+ // @ts-expect-error
9
+ (0, vitest_1.expect)(() => (0, bundle_1.bundle)({})).rejects.toThrow(/bundle\(\) was called without the `entryPoint` option/);
10
+ });
@@ -1,11 +1,11 @@
1
1
  import type { WebpackConfiguration, WebpackOverrideFn } from 'remotion';
2
- export declare const webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgressUpdate, enableCaching, envVariables, maxTimelineTracks, entryPoints, remotionRoot, keyboardShortcutsEnabled, }: {
2
+ export declare const webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgress, enableCaching, envVariables, maxTimelineTracks, entryPoints, remotionRoot, keyboardShortcutsEnabled, }: {
3
3
  entry: string;
4
4
  userDefinedComponent: string;
5
5
  outDir: string;
6
6
  environment: 'development' | 'production';
7
7
  webpackOverride: WebpackOverrideFn;
8
- onProgressUpdate?: ((f: number) => void) | undefined;
8
+ onProgress?: ((f: number) => void) | undefined;
9
9
  enableCaching?: boolean | undefined;
10
10
  envVariables: Record<string, string>;
11
11
  maxTimelineTracks: number;
@@ -50,7 +50,7 @@ const esbuildLoaderOptions = {
50
50
  function truthy(value) {
51
51
  return Boolean(value);
52
52
  }
53
- const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpackOverride = (f) => f, onProgressUpdate, enableCaching = true, envVariables, maxTimelineTracks, entryPoints, remotionRoot, keyboardShortcutsEnabled, }) => {
53
+ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpackOverride = (f) => f, onProgress, enableCaching = true, envVariables, maxTimelineTracks, entryPoints, remotionRoot, keyboardShortcutsEnabled, }) => {
54
54
  const conf = webpackOverride({
55
55
  optimization: {
56
56
  minimize: false,
@@ -95,8 +95,8 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
95
95
  ]
96
96
  : [
97
97
  new webpack_1.ProgressPlugin((p) => {
98
- if (onProgressUpdate) {
99
- onProgressUpdate(Number((p * 100).toFixed(2)));
98
+ if (onProgress) {
99
+ onProgress(Number((p * 100).toFixed(2)));
100
100
  }
101
101
  }),
102
102
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/bundler",
3
- "version": "3.2.15",
3
+ "version": "3.2.20",
4
4
  "description": "Bundler for Remotion",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -26,7 +26,7 @@
26
26
  "css-loader": "5.2.7",
27
27
  "esbuild": "0.14.19",
28
28
  "react-refresh": "0.9.0",
29
- "remotion": "3.2.15",
29
+ "remotion": "3.2.20",
30
30
  "style-loader": "2.0.0",
31
31
  "webpack": "5.72.0"
32
32
  },
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "7346704683815d274733cb3d280157b9ff570773"
67
+ "gitHead": "640f36c0c2d9fb1b7768925bf9d64840cbc31bc6"
68
68
  }