@remotion/bundler 4.0.0-webhook.26 → 4.1.0-alpha1

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 (47) hide show
  1. package/LICENSE.md +8 -8
  2. package/dist/bundle-mode.d.ts +0 -0
  3. package/dist/bundle-mode.js +0 -0
  4. package/dist/bundle.d.ts +12 -4
  5. package/dist/bundle.js +111 -25
  6. package/dist/copy-dir.d.ts +9 -1
  7. package/dist/copy-dir.js +25 -9
  8. package/dist/esbuild-loader/index.d.ts +0 -0
  9. package/dist/esbuild-loader/index.js +2 -2
  10. package/dist/esbuild-loader/interfaces.d.ts +3 -3
  11. package/dist/esbuild-loader/interfaces.js +0 -0
  12. package/dist/fast-refresh/helpers.d.ts +0 -0
  13. package/dist/fast-refresh/helpers.js +2 -2
  14. package/dist/fast-refresh/index.d.ts +0 -0
  15. package/dist/fast-refresh/index.js +0 -0
  16. package/dist/fast-refresh/loader.d.ts +94 -0
  17. package/dist/fast-refresh/loader.js +8 -15
  18. package/dist/fast-refresh/runtime.d.ts +0 -0
  19. package/dist/fast-refresh/runtime.js +0 -1
  20. package/dist/homepage/homepage.d.ts +0 -0
  21. package/dist/homepage/homepage.js +53 -9
  22. package/dist/index-html.d.ts +39 -2
  23. package/dist/index-html.js +17 -7
  24. package/dist/index.d.ts +21 -8
  25. package/dist/index.js +2 -0
  26. package/dist/optional-dependencies.d.ts +5 -0
  27. package/dist/optional-dependencies.js +27 -0
  28. package/dist/read-recursively.d.ts +8 -0
  29. package/dist/read-recursively.js +78 -0
  30. package/dist/renderEntry.d.ts +0 -0
  31. package/dist/renderEntry.js +42 -16
  32. package/dist/setup-environment.d.ts +0 -0
  33. package/dist/setup-environment.js +81 -0
  34. package/dist/stringify-with-circular-references.d.ts +1 -0
  35. package/dist/stringify-with-circular-references.js +18 -0
  36. package/dist/test/validate-bundle.test.d.ts +0 -0
  37. package/dist/test/validate-bundle.test.js +0 -0
  38. package/dist/test/validate-public-dir.test.d.ts +0 -0
  39. package/dist/test/validate-public-dir.test.js +2 -2
  40. package/dist/validate-public-dir.d.ts +0 -0
  41. package/dist/validate-public-dir.js +6 -6
  42. package/dist/webpack-cache.d.ts +4 -3
  43. package/dist/webpack-cache.js +24 -23
  44. package/dist/webpack-config.d.ts +6 -4
  45. package/dist/webpack-config.js +16 -14
  46. package/package.json +64 -67
  47. package/react-shim.js +5 -1
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.validatePublicDir = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  const validatePublicDir = (p) => {
10
- const { root } = path_1.default.parse(process.cwd());
10
+ const { root } = node_path_1.default.parse(process.cwd());
11
11
  if (p === root) {
12
12
  throw new Error(`The public directory was specified as "${p}", which is the root directory. This is not allowed.`);
13
13
  }
14
14
  try {
15
- const stat = fs_1.default.lstatSync(p);
15
+ const stat = node_fs_1.default.lstatSync(p);
16
16
  if (!stat.isDirectory()) {
17
17
  throw new Error(`The public directory was specified as "${p}", and while this path exists on the filesystem, it is not a directory.`);
18
18
  }
@@ -20,8 +20,8 @@ const validatePublicDir = (p) => {
20
20
  catch (e) {
21
21
  // Path does not exist
22
22
  // Check if the parent path exists
23
- const parentPath = path_1.default.dirname(p);
24
- const exists = fs_1.default.existsSync(parentPath);
23
+ const parentPath = node_path_1.default.dirname(p);
24
+ const exists = node_fs_1.default.existsSync(parentPath);
25
25
  if (!exists) {
26
26
  throw new Error(`The public directory was specified as "${p}", but this folder does not exist and the parent directory "${parentPath}" does also not exist. Create at least the parent directory.`);
27
27
  }
@@ -1,5 +1,5 @@
1
- declare type Environment = 'development' | 'production';
2
- declare type CacheState = 'exists' | 'other-exists' | 'does-not-exist';
1
+ type Environment = 'development' | 'production';
2
+ type CacheState = 'exists' | 'other-exists' | 'does-not-exist';
3
3
  declare global {
4
4
  namespace NodeJS {
5
5
  interface ProcessVersions {
@@ -7,7 +7,8 @@ declare global {
7
7
  }
8
8
  }
9
9
  }
10
- export declare const clearCache: (remotionRoot: string) => Promise<void>;
10
+ export declare const clearCache: (remotionRoot: string, env: Environment) => Promise<void>;
11
+ export declare const getWebpackCacheEnvDir: (environment: Environment) => string;
11
12
  export declare const getWebpackCacheName: (environment: Environment, hash: string) => string;
12
13
  export declare const cacheExists: (remotionRoot: string, environment: Environment, hash: string) => CacheState;
13
14
  export {};
@@ -3,22 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.cacheExists = exports.getWebpackCacheName = exports.clearCache = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
6
+ exports.cacheExists = exports.getWebpackCacheName = exports.getWebpackCacheEnvDir = exports.clearCache = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node: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
11
  const getWebpackCacheDir = (remotionRoot) => {
12
12
  let dir = remotionRoot;
13
13
  for (;;) {
14
14
  try {
15
- if (fs_1.default.statSync(path_1.default.join(dir, 'package.json')).isFile()) {
15
+ if (node_fs_1.default.statSync(node_path_1.default.join(dir, 'package.json')).isFile()) {
16
16
  break;
17
17
  }
18
18
  // eslint-disable-next-line no-empty
19
19
  }
20
20
  catch (e) { }
21
- const parent = path_1.default.dirname(dir);
21
+ const parent = node_path_1.default.dirname(dir);
22
22
  if (dir === parent) {
23
23
  dir = undefined;
24
24
  break;
@@ -26,40 +26,41 @@ const getWebpackCacheDir = (remotionRoot) => {
26
26
  dir = parent;
27
27
  }
28
28
  if (!dir) {
29
- return path_1.default.resolve(remotionRoot, '.cache/webpack');
29
+ return node_path_1.default.resolve(remotionRoot, '.cache/webpack');
30
30
  }
31
31
  if (process.versions.pnp === '1') {
32
- return path_1.default.resolve(dir, '.pnp/.cache/webpack');
32
+ return node_path_1.default.resolve(dir, '.pnp/.cache/webpack');
33
33
  }
34
34
  if (process.versions.pnp === '3') {
35
- return path_1.default.resolve(dir, '.yarn/.cache/webpack');
35
+ return node_path_1.default.resolve(dir, '.yarn/.cache/webpack');
36
36
  }
37
- return path_1.default.resolve(dir, 'node_modules/.cache/webpack');
37
+ return node_path_1.default.resolve(dir, 'node_modules/.cache/webpack');
38
+ };
39
+ const remotionCacheLocationForEnv = (remotionRoot, environment) => {
40
+ return node_path_1.default.join(getWebpackCacheDir(remotionRoot), (0, exports.getWebpackCacheEnvDir)(environment));
38
41
  };
39
42
  const remotionCacheLocation = (remotionRoot, environment, hash) => {
40
- return path_1.default.join(getWebpackCacheDir(remotionRoot), (0, exports.getWebpackCacheName)(environment, hash));
43
+ return node_path_1.default.join(getWebpackCacheDir(remotionRoot), (0, exports.getWebpackCacheName)(environment, hash));
41
44
  };
42
- const clearCache = (remotionRoot) => {
43
- var _a;
44
- return ((_a = fs_1.default.promises.rm) !== null && _a !== void 0 ? _a : fs_1.default.promises.rmdir)(getWebpackCacheDir(remotionRoot), {
45
+ const clearCache = (remotionRoot, env) => {
46
+ return node_fs_1.default.promises.rm(remotionCacheLocationForEnv(remotionRoot, env), {
45
47
  recursive: true,
46
48
  });
47
49
  };
48
50
  exports.clearCache = clearCache;
49
51
  const getPrefix = (environment) => {
50
- return `remotion-v4-${environment}`;
52
+ return `remotion-v5-${environment}`;
53
+ };
54
+ const getWebpackCacheEnvDir = (environment) => {
55
+ return getPrefix(environment);
51
56
  };
57
+ exports.getWebpackCacheEnvDir = getWebpackCacheEnvDir;
52
58
  const getWebpackCacheName = (environment, hash) => {
53
- if (environment === 'development') {
54
- return `${getPrefix(environment)}-${hash}`;
55
- }
56
- // In production, the cache is independent from input props because
57
- // they are passed over URL params. Speed is mostly important in production.
58
- return `${getPrefix(environment)}-${hash}`;
59
+ return [(0, exports.getWebpackCacheEnvDir)(environment), hash].join(node_path_1.default.sep);
59
60
  };
60
61
  exports.getWebpackCacheName = getWebpackCacheName;
61
62
  const hasOtherCache = ({ remotionRoot, environment, }) => {
62
- const cacheDir = fs_1.default.readdirSync(getWebpackCacheDir(remotionRoot));
63
+ const cacheDir = node_fs_1.default.readdirSync(getWebpackCacheDir(remotionRoot));
63
64
  if (cacheDir.find((c) => {
64
65
  return c.startsWith(getPrefix(environment));
65
66
  })) {
@@ -68,10 +69,10 @@ const hasOtherCache = ({ remotionRoot, environment, }) => {
68
69
  return false;
69
70
  };
70
71
  const cacheExists = (remotionRoot, environment, hash) => {
71
- if (fs_1.default.existsSync(remotionCacheLocation(remotionRoot, environment, hash))) {
72
+ if (node_fs_1.default.existsSync(remotionCacheLocation(remotionRoot, environment, hash))) {
72
73
  return 'exists';
73
74
  }
74
- if (!fs_1.default.existsSync(getWebpackCacheDir(remotionRoot))) {
75
+ if (!node_fs_1.default.existsSync(getWebpackCacheDir(remotionRoot))) {
75
76
  return 'does-not-exist';
76
77
  }
77
78
  if (hasOtherCache({ remotionRoot, environment })) {
@@ -1,15 +1,17 @@
1
- import type { WebpackConfiguration, WebpackOverrideFn } from 'remotion';
2
- export declare const webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgress, enableCaching, envVariables, maxTimelineTracks, entryPoints, remotionRoot, keyboardShortcutsEnabled, }: {
1
+ import type { Configuration } from 'webpack';
2
+ export type WebpackConfiguration = Configuration;
3
+ export type WebpackOverrideFn = (currentConfiguration: WebpackConfiguration) => WebpackConfiguration;
4
+ export declare const webpackConfig: ({ entry, userDefinedComponent, outDir, environment, webpackOverride, onProgress, enableCaching, maxTimelineTracks, entryPoints, remotionRoot, keyboardShortcutsEnabled, poll, }: {
3
5
  entry: string;
4
6
  userDefinedComponent: string;
5
- outDir: string;
7
+ outDir: string | null;
6
8
  environment: 'development' | 'production';
7
9
  webpackOverride: WebpackOverrideFn;
8
10
  onProgress?: ((f: number) => void) | undefined;
9
11
  enableCaching?: boolean | undefined;
10
- envVariables: Record<string, string>;
11
12
  maxTimelineTracks: number;
12
13
  keyboardShortcutsEnabled: boolean;
13
14
  entryPoints: string[];
14
15
  remotionRoot: string;
16
+ poll: number | null;
15
17
  }) => [string, WebpackConfiguration];
@@ -27,14 +27,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.webpackConfig = void 0;
30
- const crypto_1 = require("crypto");
30
+ const node_crypto_1 = require("node:crypto");
31
31
  const react_dom_1 = __importDefault(require("react-dom"));
32
- const remotion_1 = require("remotion");
33
32
  const webpack_1 = __importStar(require("webpack"));
34
33
  const fast_refresh_1 = require("./fast-refresh");
34
+ const stringify_with_circular_references_1 = require("./stringify-with-circular-references");
35
35
  const webpack_cache_1 = require("./webpack-cache");
36
36
  const esbuild = require("esbuild");
37
- if (!react_dom_1.default || !react_dom_1.default.version) {
37
+ const remotion_1 = require("remotion");
38
+ const optional_dependencies_1 = require("./optional-dependencies");
39
+ if (!(react_dom_1.default === null || react_dom_1.default === void 0 ? void 0 : react_dom_1.default.version)) {
38
40
  throw new Error('Could not find "react-dom" package. Did you install it?');
39
41
  }
40
42
  const reactDomVersion = react_dom_1.default.version.split('.')[0];
@@ -50,7 +52,7 @@ const esbuildLoaderOptions = {
50
52
  function truthy(value) {
51
53
  return Boolean(value);
52
54
  }
53
- const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpackOverride = (f) => f, onProgress, enableCaching = true, envVariables, maxTimelineTracks, entryPoints, remotionRoot, keyboardShortcutsEnabled, }) => {
55
+ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpackOverride = (f) => f, onProgress, enableCaching = true, maxTimelineTracks, entryPoints, remotionRoot, keyboardShortcutsEnabled, poll, }) => {
54
56
  const conf = webpackOverride({
55
57
  optimization: {
56
58
  minimize: false,
@@ -63,12 +65,11 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
63
65
  },
64
66
  },
65
67
  watchOptions: {
68
+ poll: poll !== null && poll !== void 0 ? poll : undefined,
66
69
  aggregateTimeout: 0,
67
70
  ignored: ['**/.git/**', '**/node_modules/**'],
68
71
  },
69
- devtool: environment === 'development'
70
- ? 'cheap-module-source-map'
71
- : 'cheap-module-source-map',
72
+ devtool: 'cheap-module-source-map',
72
73
  entry: [
73
74
  // Fast Refresh must come first,
74
75
  // because setup-environment imports ReactDOM.
@@ -90,8 +91,8 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
90
91
  new webpack_1.default.DefinePlugin({
91
92
  'process.env.MAX_TIMELINE_TRACKS': maxTimelineTracks,
92
93
  'process.env.KEYBOARD_SHORTCUTS_ENABLED': keyboardShortcutsEnabled,
93
- [`process.env.${remotion_1.Internals.ENV_VARIABLES_ENV_NAME}`]: JSON.stringify(envVariables),
94
94
  }),
95
+ new optional_dependencies_1.AllowOptionalDependenciesPlugin(),
95
96
  ]
96
97
  : [
97
98
  new webpack_1.ProgressPlugin((p) => {
@@ -99,16 +100,16 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
99
100
  onProgress(Number((p * 100).toFixed(2)));
100
101
  }
101
102
  }),
103
+ new optional_dependencies_1.AllowOptionalDependenciesPlugin(),
102
104
  ],
103
105
  output: {
104
106
  hashFunction: 'xxhash64',
105
- globalObject: 'this',
106
- filename: 'bundle.js',
107
+ filename: remotion_1.Internals.bundleName,
107
108
  devtoolModuleFilenameTemplate: '[resource-path]',
108
109
  assetModuleFilename: environment === 'development' ? '[path][name][ext]' : '[hash][ext]',
109
110
  },
110
111
  resolve: {
111
- extensions: ['.ts', '.tsx', '.js', '.jsx'],
112
+ extensions: ['.ts', '.tsx', '.web.js', '.js', '.jsx'],
112
113
  alias: {
113
114
  // Only one version of react
114
115
  'react/jsx-runtime': require.resolve('react/jsx-runtime'),
@@ -117,7 +118,6 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
117
118
  ? require.resolve('react-dom/client')
118
119
  : require.resolve('react-dom'),
119
120
  remotion: require.resolve('remotion'),
120
- 'react-native$': 'react-native-web',
121
121
  },
122
122
  },
123
123
  module: {
@@ -168,7 +168,9 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
168
168
  ],
169
169
  },
170
170
  });
171
- const hash = (0, crypto_1.createHash)('md5').update(JSON.stringify(conf)).digest('hex');
171
+ const hash = (0, node_crypto_1.createHash)('md5')
172
+ .update((0, stringify_with_circular_references_1.jsonStringifyWithCircularReferences)(conf))
173
+ .digest('hex');
172
174
  return [
173
175
  hash,
174
176
  {
@@ -182,7 +184,7 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
182
184
  : false,
183
185
  output: {
184
186
  ...conf.output,
185
- path: outDir,
187
+ ...(outDir ? { path: outDir } : {}),
186
188
  },
187
189
  context: remotionRoot,
188
190
  },
package/package.json CHANGED
@@ -1,68 +1,65 @@
1
1
  {
2
- "name": "@remotion/bundler",
3
- "version": "4.0.0-webhook.26+c8e41db11",
4
- "description": "Bundler for Remotion",
5
- "main": "dist/index.js",
6
- "sideEffects": false,
7
- "repository": {
8
- "url": "https://github.com/remotion-dev/remotion"
9
- },
10
- "bugs": {
11
- "url": "https://github.com/remotion-dev/remotion/issues"
12
- },
13
- "scripts": {
14
- "lint": "eslint src --ext ts,tsx",
15
- "build": "tsc -d",
16
- "watch": "tsc -w",
17
- "test": "vitest --run"
18
- },
19
- "files": [
20
- "dist",
21
- "react-shim.js"
22
- ],
23
- "author": "",
24
- "license": "SEE LICENSE IN LICENSE.md",
25
- "dependencies": {
26
- "css-loader": "5.2.7",
27
- "esbuild": "0.14.19",
28
- "react-refresh": "0.9.0",
29
- "remotion": "4.0.0-webhook.26+c8e41db11",
30
- "style-loader": "2.0.0",
31
- "webpack": "5.74.0"
32
- },
33
- "peerDependencies": {
34
- "react": ">=16.8.0",
35
- "react-dom": ">=16.8.0"
36
- },
37
- "devDependencies": {
38
- "@jonny/eslint-config": "3.0.266",
39
- "@types/node": "^16.7.5",
40
- "@types/react": "18.0.1",
41
- "@types/react-dom": "18.0.0",
42
- "@types/webpack-env": "^1.16.0",
43
- "@typescript-eslint/eslint-plugin": "5.18.0",
44
- "@typescript-eslint/parser": "5.18.0",
45
- "eslint": "8.13.0",
46
- "eslint-plugin-10x": "1.5.2",
47
- "eslint-plugin-react": "7.29.4",
48
- "eslint-plugin-react-hooks": "4.4.0",
49
- "prettier": "^2.0.5",
50
- "prettier-plugin-organize-imports": "^2.3.4",
51
- "react": "^18.0.0",
52
- "react-dom": "^18.0.0",
53
- "typescript": "^4.7.0",
54
- "vitest": "^0.18.0"
55
- },
56
- "keywords": [
57
- "remotion",
58
- "ffmpeg",
59
- "video",
60
- "react",
61
- "puppeteer",
62
- "player"
63
- ],
64
- "publishConfig": {
65
- "access": "public"
66
- },
67
- "gitHead": "c8e41db114d645c5183edbf016a22b733243dce2"
68
- }
2
+ "name": "@remotion/bundler",
3
+ "version": "4.1.0-alpha1",
4
+ "description": "Bundler for Remotion",
5
+ "main": "dist/index.js",
6
+ "sideEffects": false,
7
+ "repository": {
8
+ "url": "https://github.com/remotion-dev/remotion"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/remotion-dev/remotion/issues"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "react-shim.js"
16
+ ],
17
+ "author": "Jonny Burger <jonny@remotion.dev>",
18
+ "license": "SEE LICENSE IN LICENSE.md",
19
+ "dependencies": {
20
+ "css-loader": "5.2.7",
21
+ "esbuild": "0.16.12",
22
+ "react-refresh": "0.9.0",
23
+ "style-loader": "2.0.0",
24
+ "webpack": "5.83.1",
25
+ "remotion": "4.1.0-alpha1"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=16.8.0",
29
+ "react-dom": ">=16.8.0"
30
+ },
31
+ "devDependencies": {
32
+ "@jonny/eslint-config": "3.0.266",
33
+ "@types/node": "18.14.6",
34
+ "@types/react": "18.0.26",
35
+ "@types/react-dom": "18.0.10",
36
+ "eslint": "8.42.0",
37
+ "eslint-plugin-10x": "1.5.2",
38
+ "eslint-plugin-react": "7.29.4",
39
+ "eslint-plugin-react-hooks": "4.4.0",
40
+ "prettier": "^2.7.1",
41
+ "prettier-plugin-organize-imports": "^2.3.4",
42
+ "react": "^18.0.0",
43
+ "react-dom": "^18.0.0",
44
+ "typescript": "4.9.5",
45
+ "vitest": "0.31.1"
46
+ },
47
+ "keywords": [
48
+ "remotion",
49
+ "ffmpeg",
50
+ "video",
51
+ "react",
52
+ "webpack",
53
+ "player"
54
+ ],
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "scripts": {
59
+ "formatting": "prettier src --check",
60
+ "lint": "eslint src --ext ts,tsx",
61
+ "build": "tsc -d",
62
+ "watch": "tsc -w",
63
+ "test": "vitest --run"
64
+ }
65
+ }
package/react-shim.js CHANGED
@@ -1,3 +1,7 @@
1
1
  import * as React from 'react';
2
2
 
3
- window.React = React;
3
+ if (typeof globalThis === 'undefined') {
4
+ window.React = React;
5
+ } else {
6
+ globalThis.React = React;
7
+ }