@remotion/bundler 3.1.4 → 3.1.7

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.
Files changed (148) hide show
  1. package/dist/bundle.d.ts +10 -4
  2. package/dist/bundle.js +36 -11
  3. package/dist/esbuild-loader/index.js +1 -1
  4. package/dist/index-html.d.ts +7 -1
  5. package/dist/index-html.js +3 -3
  6. package/dist/index.d.ts +21 -12
  7. package/dist/setup-environment.js +0 -1
  8. package/dist/webpack-cache.d.ts +2 -2
  9. package/dist/webpack-cache.js +13 -14
  10. package/dist/webpack-config.d.ts +2 -1
  11. package/dist/webpack-config.js +2 -1
  12. package/package.json +3 -3
  13. package/dist/bundler.d.ts +0 -7
  14. package/dist/bundler.js +0 -76
  15. package/dist/dev-middleware/compatible-api.d.ts +0 -10
  16. package/dist/dev-middleware/compatible-api.js +0 -44
  17. package/dist/dev-middleware/get-filename-from-url.d.ts +0 -2
  18. package/dist/dev-middleware/get-filename-from-url.js +0 -92
  19. package/dist/dev-middleware/get-paths.d.ts +0 -7
  20. package/dist/dev-middleware/get-paths.js +0 -19
  21. package/dist/dev-middleware/index.d.ts +0 -3
  22. package/dist/dev-middleware/index.js +0 -57
  23. package/dist/dev-middleware/is-color-supported.d.ts +0 -1
  24. package/dist/dev-middleware/is-color-supported.js +0 -37
  25. package/dist/dev-middleware/middleware.d.ts +0 -4
  26. package/dist/dev-middleware/middleware.js +0 -141
  27. package/dist/dev-middleware/range-parser.d.ts +0 -15
  28. package/dist/dev-middleware/range-parser.js +0 -96
  29. package/dist/dev-middleware/ready.d.ts +0 -5
  30. package/dist/dev-middleware/ready.js +0 -13
  31. package/dist/dev-middleware/setup-hooks.d.ts +0 -2
  32. package/dist/dev-middleware/setup-hooks.js +0 -44
  33. package/dist/dev-middleware/setup-output-filesystem.d.ts +0 -2
  34. package/dist/dev-middleware/setup-output-filesystem.js +0 -13
  35. package/dist/dev-middleware/types.d.ts +0 -11
  36. package/dist/dev-middleware/types.js +0 -2
  37. package/dist/error-overlay/entry-basic.d.ts +0 -1
  38. package/dist/error-overlay/entry-basic.js +0 -21
  39. package/dist/error-overlay/react-overlay/effects/format-warning.d.ts +0 -11
  40. package/dist/error-overlay/react-overlay/effects/format-warning.js +0 -41
  41. package/dist/error-overlay/react-overlay/effects/map-error-to-react-stack.d.ts +0 -7
  42. package/dist/error-overlay/react-overlay/effects/map-error-to-react-stack.js +0 -46
  43. package/dist/error-overlay/react-overlay/effects/proxy-console.d.ts +0 -24
  44. package/dist/error-overlay/react-overlay/effects/proxy-console.js +0 -63
  45. package/dist/error-overlay/react-overlay/effects/resolve-file-source.d.ts +0 -3
  46. package/dist/error-overlay/react-overlay/effects/resolve-file-source.js +0 -31
  47. package/dist/error-overlay/react-overlay/effects/stack-trace-limit.d.ts +0 -3
  48. package/dist/error-overlay/react-overlay/effects/stack-trace-limit.js +0 -43
  49. package/dist/error-overlay/react-overlay/effects/unhandled-error.d.ts +0 -4
  50. package/dist/error-overlay/react-overlay/effects/unhandled-error.js +0 -45
  51. package/dist/error-overlay/react-overlay/effects/unhandled-rejection.d.ts +0 -4
  52. package/dist/error-overlay/react-overlay/effects/unhandled-rejection.js +0 -41
  53. package/dist/error-overlay/react-overlay/index.d.ts +0 -2
  54. package/dist/error-overlay/react-overlay/index.js +0 -21
  55. package/dist/error-overlay/react-overlay/listen-to-runtime-errors.d.ts +0 -8
  56. package/dist/error-overlay/react-overlay/listen-to-runtime-errors.js +0 -78
  57. package/dist/error-overlay/react-overlay/utils/get-file-source.d.ts +0 -1
  58. package/dist/error-overlay/react-overlay/utils/get-file-source.js +0 -21
  59. package/dist/error-overlay/react-overlay/utils/get-lines-around.d.ts +0 -14
  60. package/dist/error-overlay/react-overlay/utils/get-lines-around.js +0 -24
  61. package/dist/error-overlay/react-overlay/utils/get-source-map.d.ts +0 -13
  62. package/dist/error-overlay/react-overlay/utils/get-source-map.js +0 -58
  63. package/dist/error-overlay/react-overlay/utils/get-stack-frames.d.ts +0 -2
  64. package/dist/error-overlay/react-overlay/utils/get-stack-frames.js +0 -27
  65. package/dist/error-overlay/react-overlay/utils/open-in-editor.d.ts +0 -12
  66. package/dist/error-overlay/react-overlay/utils/open-in-editor.js +0 -459
  67. package/dist/error-overlay/react-overlay/utils/parser.d.ts +0 -2
  68. package/dist/error-overlay/react-overlay/utils/parser.js +0 -117
  69. package/dist/error-overlay/react-overlay/utils/stack-frame.d.ts +0 -40
  70. package/dist/error-overlay/react-overlay/utils/stack-frame.js +0 -31
  71. package/dist/error-overlay/react-overlay/utils/unmapper.d.ts +0 -2
  72. package/dist/error-overlay/react-overlay/utils/unmapper.js +0 -64
  73. package/dist/error-overlay/remotion-overlay/AskOnDiscord.d.ts +0 -2
  74. package/dist/error-overlay/remotion-overlay/AskOnDiscord.js +0 -14
  75. package/dist/error-overlay/remotion-overlay/Button.d.ts +0 -6
  76. package/dist/error-overlay/remotion-overlay/Button.js +0 -24
  77. package/dist/error-overlay/remotion-overlay/CodeFrame.d.ts +0 -6
  78. package/dist/error-overlay/remotion-overlay/CodeFrame.js +0 -28
  79. package/dist/error-overlay/remotion-overlay/DismissButton.d.ts +0 -2
  80. package/dist/error-overlay/remotion-overlay/DismissButton.js +0 -23
  81. package/dist/error-overlay/remotion-overlay/ErrorDisplay.d.ts +0 -5
  82. package/dist/error-overlay/remotion-overlay/ErrorDisplay.js +0 -45
  83. package/dist/error-overlay/remotion-overlay/ErrorLoader.d.ts +0 -4
  84. package/dist/error-overlay/remotion-overlay/ErrorLoader.js +0 -61
  85. package/dist/error-overlay/remotion-overlay/ErrorTitle.d.ts +0 -6
  86. package/dist/error-overlay/remotion-overlay/ErrorTitle.js +0 -41
  87. package/dist/error-overlay/remotion-overlay/OpenInEditor.d.ts +0 -5
  88. package/dist/error-overlay/remotion-overlay/OpenInEditor.js +0 -90
  89. package/dist/error-overlay/remotion-overlay/Overlay.d.ts +0 -14
  90. package/dist/error-overlay/remotion-overlay/Overlay.js +0 -49
  91. package/dist/error-overlay/remotion-overlay/SearchGitHubIssues.d.ts +0 -4
  92. package/dist/error-overlay/remotion-overlay/SearchGitHubIssues.js +0 -13
  93. package/dist/error-overlay/remotion-overlay/StackFrame.d.ts +0 -8
  94. package/dist/error-overlay/remotion-overlay/StackFrame.js +0 -48
  95. package/dist/error-overlay/remotion-overlay/Symbolicating.d.ts +0 -2
  96. package/dist/error-overlay/remotion-overlay/Symbolicating.js +0 -8
  97. package/dist/error-overlay/remotion-overlay/carets.d.ts +0 -3
  98. package/dist/error-overlay/remotion-overlay/carets.js +0 -12
  99. package/dist/error-overlay/remotion-overlay/format-location.d.ts +0 -1
  100. package/dist/error-overlay/remotion-overlay/format-location.js +0 -10
  101. package/dist/error-overlay/remotion-overlay/index.d.ts +0 -1
  102. package/dist/error-overlay/remotion-overlay/index.js +0 -18
  103. package/dist/get-latest-remotion-version.d.ts +0 -1
  104. package/dist/get-latest-remotion-version.js +0 -31
  105. package/dist/get-package-manager.d.ts +0 -8
  106. package/dist/get-package-manager.js +0 -38
  107. package/dist/get-port.d.ts +0 -1
  108. package/dist/get-port.js +0 -80
  109. package/dist/hot-middleware/client.d.ts +0 -19
  110. package/dist/hot-middleware/client.js +0 -206
  111. package/dist/hot-middleware/index.d.ts +0 -13
  112. package/dist/hot-middleware/index.js +0 -180
  113. package/dist/hot-middleware/process-update.d.ts +0 -12
  114. package/dist/hot-middleware/process-update.js +0 -147
  115. package/dist/hot-middleware/strip-ansi.d.ts +0 -1
  116. package/dist/hot-middleware/strip-ansi.js +0 -21
  117. package/dist/hot-middleware/types.d.ts +0 -37
  118. package/dist/hot-middleware/types.js +0 -17
  119. package/dist/is-path-inside.d.ts +0 -1
  120. package/dist/is-path-inside.js +0 -27
  121. package/dist/p-limit.d.ts +0 -1
  122. package/dist/p-limit.js +0 -57
  123. package/dist/project-info.d.ts +0 -5
  124. package/dist/project-info.js +0 -22
  125. package/dist/routes.d.ts +0 -2
  126. package/dist/routes.js +0 -121
  127. package/dist/serve-static.d.ts +0 -9
  128. package/dist/serve-static.js +0 -81
  129. package/dist/start-server-pure.d.ts +0 -8
  130. package/dist/start-server-pure.js +0 -68
  131. package/dist/start-server.d.ts +0 -8
  132. package/dist/start-server.js +0 -132
  133. package/dist/static-preview.d.ts +0 -1
  134. package/dist/static-preview.js +0 -40
  135. package/dist/test/expect-to-throw.d.ts +0 -1
  136. package/dist/test/expect-to-throw.js +0 -14
  137. package/dist/test/latest-remotion-version.test.d.ts +0 -1
  138. package/dist/test/latest-remotion-version.test.js +0 -6
  139. package/dist/test/parse-error-stack.test.d.ts +0 -1
  140. package/dist/test/parse-error-stack.test.js +0 -17
  141. package/dist/test/parse-module-not-found.test.d.ts +0 -1
  142. package/dist/test/parse-module-not-found.test.js +0 -17
  143. package/dist/test/secure-source-read.test.d.ts +0 -1
  144. package/dist/test/secure-source-read.test.js +0 -8
  145. package/dist/ts-alias-plugin.d.ts +0 -4
  146. package/dist/ts-alias-plugin.js +0 -21
  147. package/dist/update-available.d.ts +0 -10
  148. package/dist/update-available.js +0 -36
package/dist/bundle.d.ts CHANGED
@@ -1,11 +1,17 @@
1
1
  import type { WebpackOverrideFn } from 'remotion';
2
2
  import webpack from 'webpack';
3
- declare type Options = {
3
+ export declare type BundleOptions = {
4
4
  webpackOverride?: WebpackOverrideFn;
5
5
  outDir?: string;
6
6
  enableCaching?: boolean;
7
7
  publicPath?: string;
8
+ rootDir?: string;
8
9
  };
9
- export declare const getConfig: (outDir: string, entryPoint: string, onProgressUpdate?: ((progress: number) => void) | undefined, options?: Options) => [string, webpack.Configuration];
10
- export declare const bundle: (entryPoint: string, onProgressUpdate?: ((progress: number) => void) | undefined, options?: Options) => Promise<string>;
11
- export {};
10
+ export declare const getConfig: ({ entryPoint, outDir, resolvedRemotionRoot, onProgressUpdate, options, }: {
11
+ outDir: string;
12
+ entryPoint: string;
13
+ resolvedRemotionRoot: string;
14
+ onProgressUpdate?: ((progress: number) => void) | undefined;
15
+ options?: BundleOptions | undefined;
16
+ }) => [string, webpack.Configuration];
17
+ export declare const bundle: (entryPoint: string, onProgressUpdate?: ((progress: number) => void) | undefined, options?: BundleOptions) => Promise<string>;
package/dist/bundle.js CHANGED
@@ -7,9 +7,9 @@ exports.bundle = exports.getConfig = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const os_1 = __importDefault(require("os"));
9
9
  const path_1 = __importDefault(require("path"));
10
- const remotion_1 = require("remotion");
11
10
  const util_1 = require("util");
12
11
  const webpack_1 = __importDefault(require("webpack"));
12
+ 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");
@@ -34,28 +34,46 @@ const trimTrailingSlash = (p) => {
34
34
  }
35
35
  return p;
36
36
  };
37
- const getConfig = (outDir, entryPoint, onProgressUpdate, options) => {
37
+ const getConfig = ({ entryPoint, outDir, resolvedRemotionRoot, onProgressUpdate, options, }) => {
38
38
  var _a, _b;
39
39
  return (0, webpack_config_1.webpackConfig)({
40
40
  entry,
41
41
  userDefinedComponent: entryPoint,
42
42
  outDir,
43
43
  environment: 'production',
44
- webpackOverride: (_a = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _a !== void 0 ? _a : remotion_1.Internals.defaultOverrideFunction,
44
+ webpackOverride: (_a = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _a !== void 0 ? _a : ((f) => f),
45
45
  onProgressUpdate,
46
- enableCaching: (_b = options === null || options === void 0 ? void 0 : options.enableCaching) !== null && _b !== void 0 ? _b : remotion_1.Internals.DEFAULT_WEBPACK_CACHE_ENABLED,
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
49
49
  envVariables: {},
50
50
  entryPoints: [],
51
+ remotionRoot: resolvedRemotionRoot,
51
52
  });
52
53
  };
53
54
  exports.getConfig = getConfig;
54
55
  const bundle = async (entryPoint, onProgressUpdate, options) => {
55
- var _a, _b;
56
- const outDir = await prepareOutDir((_a = options === null || options === void 0 ? void 0 : options.outDir) !== null && _a !== void 0 ? _a : null);
57
- const [, config] = (0, exports.getConfig)(outDir, entryPoint, onProgressUpdate, options);
56
+ var _a, _b, _c;
57
+ const resolvedRemotionRoot = (_a = options === null || options === void 0 ? void 0 : options.rootDir) !== null && _a !== void 0 ? _a : process.cwd();
58
+ const outDir = await prepareOutDir((_b = options === null || options === void 0 ? void 0 : options.outDir) !== null && _b !== void 0 ? _b : null);
59
+ // The config might use an override which might use
60
+ // `process.cwd()`. The context should always be the Remotion root.
61
+ // This is not supported in worker threads (used for tests)
62
+ const currentCwd = process.cwd();
63
+ if (worker_threads_1.isMainThread) {
64
+ process.chdir(resolvedRemotionRoot);
65
+ }
66
+ const [, config] = (0, exports.getConfig)({
67
+ outDir,
68
+ entryPoint,
69
+ resolvedRemotionRoot,
70
+ onProgressUpdate,
71
+ options,
72
+ });
58
73
  const output = await promisified([config]);
74
+ if (worker_threads_1.isMainThread) {
75
+ process.chdir(currentCwd);
76
+ }
59
77
  if (!output) {
60
78
  throw new Error('Expected webpack output');
61
79
  }
@@ -63,17 +81,24 @@ const bundle = async (entryPoint, onProgressUpdate, options) => {
63
81
  if (errors !== undefined && errors.length > 0) {
64
82
  throw new Error(errors[0].message + '\n' + errors[0].details);
65
83
  }
66
- const baseDir = (_b = options === null || options === void 0 ? void 0 : options.publicPath) !== null && _b !== void 0 ? _b : '/';
67
- const publicDir = '/' +
84
+ const baseDir = (_c = options === null || options === void 0 ? void 0 : options.publicPath) !== null && _c !== void 0 ? _c : '/';
85
+ const staticHash = '/' +
68
86
  [trimTrailingSlash(trimLeadingSlash(baseDir)), 'public']
69
87
  .filter(Boolean)
70
88
  .join('/');
71
- const from = path_1.default.join(process.cwd(), 'public');
89
+ // TODO: Unhardcode public directory
90
+ const from = path_1.default.join(resolvedRemotionRoot, 'public');
72
91
  const to = path_1.default.join(outDir, 'public');
73
92
  if (fs_1.default.existsSync(from)) {
74
93
  await (0, copy_dir_1.copyDir)(from, to);
75
94
  }
76
- const html = (0, index_html_1.indexHtml)(publicDir, baseDir, null, null);
95
+ const html = (0, index_html_1.indexHtml)({
96
+ staticHash,
97
+ baseDir,
98
+ editorName: null,
99
+ inputProps: null,
100
+ remotionRoot: resolvedRemotionRoot,
101
+ });
77
102
  fs_1.default.writeFileSync(path_1.default.join(outDir, 'index.html'), html);
78
103
  return outDir;
79
104
  };
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const esbuild_1 = require("esbuild");
7
7
  const path_1 = __importDefault(require("path"));
8
- const tsConfigPath = path_1.default.join(process.cwd(), 'tsconfig.json');
9
8
  const isTsExtensionPtrn = /\.ts$/i;
10
9
  const isTypescriptInstalled = () => {
11
10
  try {
@@ -22,6 +21,7 @@ async function ESBuildLoader(source) {
22
21
  this.getOptions();
23
22
  const options = this.getOptions();
24
23
  const { implementation, ...esbuildTransformOptions } = options;
24
+ const tsConfigPath = path_1.default.join(this.context, 'tsconfig.json');
25
25
  if (implementation && typeof implementation.transform !== 'function') {
26
26
  done(new TypeError(`esbuild-loader: options.implementation.transform must be an ESBuild transform function. Received ${typeof implementation.transform}`));
27
27
  return;
@@ -1 +1,7 @@
1
- export declare const indexHtml: (staticHash: string, baseDir: string, editorName: string | null, inputProps: object | null) => string;
1
+ export declare const indexHtml: ({ baseDir, editorName, inputProps, staticHash, remotionRoot, }: {
2
+ staticHash: string;
3
+ baseDir: string;
4
+ editorName: string | null;
5
+ inputProps: object | null;
6
+ remotionRoot: string;
7
+ }) => string;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.indexHtml = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const indexHtml = (staticHash, baseDir, editorName, inputProps) => `
8
+ const indexHtml = ({ baseDir, editorName, inputProps, staticHash, remotionRoot, }) => `
9
9
  <!DOCTYPE html>
10
10
  <html lang="en">
11
11
  <head>
@@ -22,8 +22,8 @@ const indexHtml = (staticHash, baseDir, editorName, inputProps) => `
22
22
  ${editorName
23
23
  ? `<script>window.remotion_editorName = "${editorName}";</script>`
24
24
  : '<script>window.remotion_editorName = null;</script>'}
25
- <script>window.remotion_projectName = ${JSON.stringify(path_1.default.basename(process.cwd()))};</script>
26
- <script>window.remotion_cwd = ${JSON.stringify(process.cwd())};</script>
25
+ <script>window.remotion_projectName = ${JSON.stringify(path_1.default.basename(remotionRoot))};</script>
26
+ <script>window.remotion_cwd = ${JSON.stringify(remotionRoot)};</script>
27
27
  ${inputProps
28
28
  ? ` <script>window.remotion_inputProps = ${JSON.stringify(JSON.stringify(inputProps))};</script>
29
29
  `
package/dist/index.d.ts CHANGED
@@ -2,27 +2,36 @@ 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, }: {
5
+ webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgressUpdate, enableCaching, envVariables, maxTimelineTracks, entryPoints, remotionRoot, }: {
6
6
  entry: string;
7
7
  userDefinedComponent: string;
8
8
  outDir: string;
9
9
  environment: "development" | "production";
10
- webpackOverride: import("remotion").WebpackOverrideFn;
10
+ webpackOverride: import("remotion/dist/internals").WebpackOverrideFn;
11
11
  onProgressUpdate?: ((f: number) => void) | undefined;
12
12
  enableCaching?: boolean | undefined;
13
13
  envVariables: Record<string, string>;
14
14
  maxTimelineTracks: number;
15
15
  entryPoints: string[];
16
+ remotionRoot: string;
17
+ }) => [string, webpack.Configuration];
18
+ indexHtml: ({ baseDir, editorName, inputProps, staticHash, remotionRoot, }: {
19
+ staticHash: string;
20
+ baseDir: string;
21
+ editorName: string | null;
22
+ inputProps: object | null;
23
+ remotionRoot: string;
24
+ }) => string;
25
+ cacheExists: (remotionRoot: string, environment: "development" | "production", hash: string) => "exists" | "other-exists" | "does-not-exist";
26
+ clearCache: (remotionRoot: string) => Promise<void>;
27
+ getConfig: ({ entryPoint, outDir, resolvedRemotionRoot, onProgressUpdate, options, }: {
28
+ outDir: string;
29
+ entryPoint: string;
30
+ resolvedRemotionRoot: string;
31
+ onProgressUpdate?: ((progress: number) => void) | undefined;
32
+ options?: import("./bundle").BundleOptions | undefined;
16
33
  }) => [string, webpack.Configuration];
17
- indexHtml: (staticHash: string, baseDir: string, editorName: string | null, inputProps: object | null) => string;
18
- cacheExists: (environment: "development" | "production", hash: string) => "exists" | "other-exists" | "does-not-exist";
19
- clearCache: () => Promise<void>;
20
- getConfig: (outDir: string, entryPoint: string, onProgressUpdate?: ((progress: number) => void) | undefined, options?: {
21
- webpackOverride?: import("remotion").WebpackOverrideFn | undefined;
22
- outDir?: string | undefined;
23
- enableCaching?: boolean | undefined;
24
- publicPath?: string | undefined;
25
- } | undefined) => [string, webpack.Configuration];
26
34
  };
27
- export { bundle } from './bundle';
35
+ export { bundle, BundleOptions } from './bundle';
28
36
  export { webpack };
37
+ export declare type WebpackConfiguration = webpack.Configuration;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const remotion_1 = require("remotion");
4
4
  remotion_1.Internals.setupEnvVariables();
5
- remotion_1.Internals.setupPuppeteerTimeout();
6
5
  remotion_1.Internals.CSSUtils.injectCSS(`
7
6
  .css-reset * {
8
7
  font-size: 16px;
@@ -7,7 +7,7 @@ declare global {
7
7
  }
8
8
  }
9
9
  }
10
- export declare const clearCache: () => Promise<void>;
10
+ export declare const clearCache: (remotionRoot: string) => Promise<void>;
11
11
  export declare const getWebpackCacheName: (environment: Environment, hash: string) => string;
12
- export declare const cacheExists: (environment: Environment, hash: string) => CacheState;
12
+ export declare const cacheExists: (remotionRoot: string, environment: Environment, hash: string) => CacheState;
13
13
  export {};
@@ -8,9 +8,8 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  // Inlined from https://github.com/webpack/webpack/blob/4c2ee7a4ddb8db2362ca83b6c4190523387ba7ee/lib/config/defaults.js#L265
10
10
  // An algorithm to determine where Webpack will cache the depencies
11
- const getWebpackCacheDir = () => {
12
- const cwd = process.cwd();
13
- let dir = cwd;
11
+ const getWebpackCacheDir = (remotionRoot) => {
12
+ let dir = remotionRoot;
14
13
  for (;;) {
15
14
  try {
16
15
  if (fs_1.default.statSync(path_1.default.join(dir, 'package.json')).isFile()) {
@@ -27,7 +26,7 @@ const getWebpackCacheDir = () => {
27
26
  dir = parent;
28
27
  }
29
28
  if (!dir) {
30
- return path_1.default.resolve(cwd, '.cache/webpack');
29
+ return path_1.default.resolve(remotionRoot, '.cache/webpack');
31
30
  }
32
31
  if (process.versions.pnp === '1') {
33
32
  return path_1.default.resolve(dir, '.pnp/.cache/webpack');
@@ -37,12 +36,12 @@ const getWebpackCacheDir = () => {
37
36
  }
38
37
  return path_1.default.resolve(dir, 'node_modules/.cache/webpack');
39
38
  };
40
- const remotionCacheLocation = (environment, hash) => {
41
- return path_1.default.join(getWebpackCacheDir(), (0, exports.getWebpackCacheName)(environment, hash));
39
+ const remotionCacheLocation = (remotionRoot, environment, hash) => {
40
+ return path_1.default.join(getWebpackCacheDir(remotionRoot), (0, exports.getWebpackCacheName)(environment, hash));
42
41
  };
43
- const clearCache = () => {
42
+ const clearCache = (remotionRoot) => {
44
43
  var _a;
45
- return ((_a = fs_1.default.promises.rm) !== null && _a !== void 0 ? _a : fs_1.default.promises.rmdir)(getWebpackCacheDir(), {
44
+ return ((_a = fs_1.default.promises.rm) !== null && _a !== void 0 ? _a : fs_1.default.promises.rmdir)(getWebpackCacheDir(remotionRoot), {
46
45
  recursive: true,
47
46
  });
48
47
  };
@@ -59,8 +58,8 @@ const getWebpackCacheName = (environment, hash) => {
59
58
  return `${getPrefix(environment)}-${hash}`;
60
59
  };
61
60
  exports.getWebpackCacheName = getWebpackCacheName;
62
- const hasOtherCache = (environment) => {
63
- const cacheDir = fs_1.default.readdirSync(getWebpackCacheDir());
61
+ const hasOtherCache = ({ remotionRoot, environment, }) => {
62
+ const cacheDir = fs_1.default.readdirSync(getWebpackCacheDir(remotionRoot));
64
63
  if (cacheDir.find((c) => {
65
64
  return c.startsWith(getPrefix(environment));
66
65
  })) {
@@ -68,14 +67,14 @@ const hasOtherCache = (environment) => {
68
67
  }
69
68
  return false;
70
69
  };
71
- const cacheExists = (environment, hash) => {
72
- if (fs_1.default.existsSync(remotionCacheLocation(environment, hash))) {
70
+ const cacheExists = (remotionRoot, environment, hash) => {
71
+ if (fs_1.default.existsSync(remotionCacheLocation(remotionRoot, environment, hash))) {
73
72
  return 'exists';
74
73
  }
75
- if (!fs_1.default.existsSync(getWebpackCacheDir())) {
74
+ if (!fs_1.default.existsSync(getWebpackCacheDir(remotionRoot))) {
76
75
  return 'does-not-exist';
77
76
  }
78
- if (hasOtherCache(environment)) {
77
+ if (hasOtherCache({ remotionRoot, environment })) {
79
78
  return 'other-exists';
80
79
  }
81
80
  return 'does-not-exist';
@@ -1,5 +1,5 @@
1
1
  import type { WebpackConfiguration, WebpackOverrideFn } from 'remotion';
2
- export declare const webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgressUpdate, enableCaching, envVariables, maxTimelineTracks, entryPoints, }: {
2
+ export declare const webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgressUpdate, enableCaching, envVariables, maxTimelineTracks, entryPoints, remotionRoot, }: {
3
3
  entry: string;
4
4
  userDefinedComponent: string;
5
5
  outDir: string;
@@ -10,4 +10,5 @@ export declare const webpackConfig: ({ entry, userDefinedComponent, outDir, envi
10
10
  envVariables: Record<string, string>;
11
11
  maxTimelineTracks: number;
12
12
  entryPoints: string[];
13
+ remotionRoot: string;
13
14
  }) => [string, WebpackConfiguration];
@@ -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 = remotion_1.Internals.DEFAULT_WEBPACK_CACHE_ENABLED, envVariables, maxTimelineTracks, entryPoints, }) => {
53
+ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpackOverride = (f) => f, onProgressUpdate, enableCaching = true, envVariables, maxTimelineTracks, entryPoints, remotionRoot, }) => {
54
54
  const conf = webpackOverride({
55
55
  optimization: {
56
56
  minimize: false,
@@ -183,6 +183,7 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
183
183
  ...conf.output,
184
184
  path: outDir,
185
185
  },
186
+ context: remotionRoot,
186
187
  },
187
188
  ];
188
189
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/bundler",
3
- "version": "3.1.4",
3
+ "version": "3.1.7",
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.1.4",
29
+ "remotion": "3.1.7",
30
30
  "style-loader": "2.0.0",
31
31
  "webpack": "5.72.0"
32
32
  },
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "cb662e72c635e5e70c5541d85e276ce2f4075099"
66
+ "gitHead": "599379fef6043a7125d1979766f915580ec1cf77"
67
67
  }
package/dist/bundler.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { WebpackOverrideFn } from 'remotion';
2
- export declare const bundle: (entryPoint: string, onProgressUpdate?: ((progress: number) => void) | undefined, options?: {
3
- webpackOverride?: WebpackOverrideFn | undefined;
4
- outDir?: string | undefined;
5
- enableCaching?: boolean | undefined;
6
- publicPath?: string | undefined;
7
- } | undefined) => Promise<string>;
package/dist/bundler.js DELETED
@@ -1,76 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.bundle = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const os_1 = __importDefault(require("os"));
9
- const path_1 = __importDefault(require("path"));
10
- const remotion_1 = require("remotion");
11
- const util_1 = require("util");
12
- const webpack_1 = __importDefault(require("webpack"));
13
- const copy_dir_1 = require("./copy-dir");
14
- const static_preview_1 = require("./static-preview");
15
- const webpack_config_1 = require("./webpack-config");
16
- const entry = require.resolve('./renderEntry');
17
- const promisified = (0, util_1.promisify)(webpack_1.default);
18
- const prepareOutDir = async (specified) => {
19
- if (specified) {
20
- await fs_1.default.promises.mkdir(specified, { recursive: true });
21
- return specified;
22
- }
23
- return fs_1.default.promises.mkdtemp(path_1.default.join(os_1.default.tmpdir(), 'react-motion-graphics'));
24
- };
25
- const trimLeadingSlash = (p) => {
26
- if (p.startsWith('/')) {
27
- return trimLeadingSlash(p.substr(1));
28
- }
29
- return p;
30
- };
31
- const trimTrailingSlash = (p) => {
32
- if (p.endsWith('/')) {
33
- return trimTrailingSlash(p.substr(0, p.length - 1));
34
- }
35
- return p;
36
- };
37
- const bundle = async (entryPoint, onProgressUpdate, options) => {
38
- var _a, _b, _c, _d;
39
- const outDir = await prepareOutDir((_a = options === null || options === void 0 ? void 0 : options.outDir) !== null && _a !== void 0 ? _a : null);
40
- const output = await promisified([
41
- (0, webpack_config_1.webpackConfig)({
42
- entry,
43
- userDefinedComponent: entryPoint,
44
- outDir,
45
- environment: 'production',
46
- webpackOverride: (_b = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _b !== void 0 ? _b : remotion_1.Internals.defaultOverrideFunction,
47
- onProgressUpdate,
48
- enableCaching: (_c = options === null || options === void 0 ? void 0 : options.enableCaching) !== null && _c !== void 0 ? _c : remotion_1.Internals.DEFAULT_WEBPACK_CACHE_ENABLED,
49
- maxTimelineTracks: 15,
50
- // For production, the variables are set dynamically
51
- envVariables: {},
52
- inputProps: {},
53
- }),
54
- ]);
55
- if (!output) {
56
- throw new Error('Expected webpack output');
57
- }
58
- const { errors } = output.toJson();
59
- if (errors !== undefined && errors.length > 0) {
60
- throw new Error(errors[0].message + '\n' + errors[0].details);
61
- }
62
- const baseDir = (_d = options === null || options === void 0 ? void 0 : options.publicPath) !== null && _d !== void 0 ? _d : '/';
63
- const publicDir = '/' +
64
- [trimTrailingSlash(trimLeadingSlash(baseDir)), 'public']
65
- .filter(Boolean)
66
- .join('/');
67
- const from = path_1.default.join(process.cwd(), 'public');
68
- const to = path_1.default.join(outDir, 'public');
69
- if (fs_1.default.existsSync(from)) {
70
- await (0, copy_dir_1.copyDir)(from, to);
71
- }
72
- const html = (0, static_preview_1.indexHtml)(publicDir, baseDir, null);
73
- fs_1.default.writeFileSync(path_1.default.join(outDir, 'index.html'), html);
74
- return outDir;
75
- };
76
- exports.bundle = bundle;
@@ -1,10 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { Request, Response } from 'express';
4
- import { ReadStream } from 'fs';
5
- export declare function getHeaderNames(res: Response): string[];
6
- export declare function getHeaderFromRequest(req: Request, name: string): string | string[] | undefined;
7
- export declare function getHeaderFromResponse(res: Response, name: string): string;
8
- export declare function setHeaderForResponse(res: Response, name: string, value: string | number): void;
9
- export declare function setStatusCode(res: Response, code: number): void;
10
- export declare function send(req: Request, res: Response, bufferOtStream: ReadStream | string | Buffer, byteLength: number): void;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.send = exports.setStatusCode = exports.setHeaderForResponse = exports.getHeaderFromResponse = exports.getHeaderFromRequest = exports.getHeaderNames = void 0;
4
- function getHeaderNames(res) {
5
- if (typeof res.getHeaderNames !== 'function') {
6
- // @ts-expect-error
7
- return Object.keys(res._headers || {});
8
- }
9
- return res.getHeaderNames();
10
- }
11
- exports.getHeaderNames = getHeaderNames;
12
- function getHeaderFromRequest(req, name) {
13
- // Express API
14
- if (typeof req.get === 'function') {
15
- return req.get(name);
16
- }
17
- return req.headers[name];
18
- }
19
- exports.getHeaderFromRequest = getHeaderFromRequest;
20
- function getHeaderFromResponse(res, name) {
21
- return res.get(name);
22
- }
23
- exports.getHeaderFromResponse = getHeaderFromResponse;
24
- function setHeaderForResponse(res, name, value) {
25
- res.set(name, typeof value === 'number' ? String(value) : value);
26
- }
27
- exports.setHeaderForResponse = setHeaderForResponse;
28
- function setStatusCode(res, code) {
29
- res.status(code);
30
- }
31
- exports.setStatusCode = setStatusCode;
32
- function send(req, res, bufferOtStream, byteLength) {
33
- if (typeof bufferOtStream === 'string' || Buffer.isBuffer(bufferOtStream)) {
34
- res.send(bufferOtStream);
35
- return;
36
- }
37
- setHeaderForResponse(res, 'Content-Length', byteLength);
38
- if (req.method === 'HEAD') {
39
- res.end();
40
- return;
41
- }
42
- bufferOtStream.pipe(res);
43
- }
44
- exports.send = send;
@@ -1,2 +0,0 @@
1
- import { DevMiddlewareContext } from './types';
2
- export declare function getFilenameFromUrl(context: DevMiddlewareContext, url: string | undefined): string | undefined;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getFilenameFromUrl = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- // eslint-disable-next-line no-restricted-imports
9
- const querystring_1 = __importDefault(require("querystring"));
10
- const url_1 = require("url");
11
- const get_paths_1 = require("./get-paths");
12
- const cacheStore = new WeakMap();
13
- const mem = (fn, { cache = new Map() } = {}) => {
14
- const memoized = (...arguments_) => {
15
- const [key] = arguments_;
16
- const cacheItem = cache.get(key);
17
- if (cacheItem) {
18
- return cacheItem.data;
19
- }
20
- const result = fn.apply(this, arguments_);
21
- cache.set(key, {
22
- data: result,
23
- });
24
- return result;
25
- };
26
- cacheStore.set(memoized, cache);
27
- return memoized;
28
- };
29
- const memoizedParse = mem(url_1.parse);
30
- function getFilenameFromUrl(context, url) {
31
- var _a, _b;
32
- const paths = (0, get_paths_1.getPaths)(context);
33
- let foundFilename;
34
- let urlObject;
35
- try {
36
- // The `url` property of the `request` is contains only `pathname`, `search` and `hash`
37
- urlObject = memoizedParse(url, false, true);
38
- }
39
- catch (_ignoreError) {
40
- return;
41
- }
42
- for (const { publicPath, outputPath } of paths) {
43
- let filename;
44
- let publicPathObject;
45
- try {
46
- publicPathObject = memoizedParse(publicPath !== 'auto' && publicPath ? publicPath : '/', false, true);
47
- }
48
- catch (_ignoreError) {
49
- continue;
50
- }
51
- if ((_a = urlObject.pathname) === null || _a === void 0 ? void 0 : _a.startsWith(publicPathObject.pathname)) {
52
- filename = outputPath;
53
- // Strip the `pathname` property from the `publicPath` option from the start of requested url
54
- // `/complex/foo.js` => `foo.js`
55
- const pathname = urlObject.pathname.substr(publicPathObject.pathname.length);
56
- if (pathname) {
57
- filename = path_1.default.join(outputPath, querystring_1.default.unescape(pathname));
58
- }
59
- if (!context.outputFileSystem) {
60
- continue;
61
- }
62
- try {
63
- let fsStats = (_b = context.outputFileSystem) === null || _b === void 0 ? void 0 : _b.statSync(filename);
64
- if (fsStats.isFile()) {
65
- foundFilename = filename;
66
- break;
67
- }
68
- else if (fsStats.isDirectory()) {
69
- const indexValue = 'index.html';
70
- filename = path_1.default.join(filename, indexValue);
71
- // eslint-disable-next-line max-depth
72
- try {
73
- fsStats = context.outputFileSystem.statSync(filename);
74
- }
75
- catch (__ignoreError) {
76
- continue;
77
- }
78
- // eslint-disable-next-line max-depth
79
- if (fsStats.isFile()) {
80
- foundFilename = filename;
81
- break;
82
- }
83
- }
84
- }
85
- catch (_ignoreError) {
86
- continue;
87
- }
88
- }
89
- }
90
- return foundFilename;
91
- }
92
- exports.getFilenameFromUrl = getFilenameFromUrl;
@@ -1,7 +0,0 @@
1
- import { DevMiddlewareContext } from './types';
2
- declare type PublicPath = {
3
- outputPath: string;
4
- publicPath: string;
5
- };
6
- export declare function getPaths(context: DevMiddlewareContext): PublicPath[];
7
- export {};
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPaths = void 0;
4
- function getPaths(context) {
5
- const { stats } = context;
6
- const publicPaths = [];
7
- if (!stats) {
8
- return publicPaths;
9
- }
10
- const { compilation } = stats;
11
- // The `output.path` is always present and always absolute
12
- const outputPath = compilation.getPath(compilation.outputOptions.path || '');
13
- const publicPath = compilation.outputOptions.publicPath
14
- ? compilation.getPath(compilation.outputOptions.publicPath)
15
- : '';
16
- publicPaths.push({ outputPath, publicPath });
17
- return publicPaths;
18
- }
19
- exports.getPaths = getPaths;
@@ -1,3 +0,0 @@
1
- import webpack from 'webpack';
2
- import { MiddleWare } from './middleware';
3
- export declare const wdm: (compiler: webpack.Compiler) => MiddleWare;