@remotion/bundler 3.1.2 → 3.1.5
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 +6 -2
- package/dist/bundle.js +22 -18
- package/dist/index.d.ts +9 -3
- package/dist/index.js +4 -2
- package/dist/webpack-cache.d.ts +4 -3
- package/dist/webpack-cache.js +30 -9
- package/dist/webpack-config.d.ts +1 -1
- package/dist/webpack-config.js +20 -8
- package/package.json +3 -3
package/dist/bundle.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { WebpackOverrideFn } from 'remotion';
|
|
2
|
-
|
|
2
|
+
import webpack from 'webpack';
|
|
3
|
+
declare type Options = {
|
|
3
4
|
webpackOverride?: WebpackOverrideFn;
|
|
4
5
|
outDir?: string;
|
|
5
6
|
enableCaching?: boolean;
|
|
6
7
|
publicPath?: string;
|
|
7
|
-
}
|
|
8
|
+
};
|
|
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 {};
|
package/dist/bundle.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.bundle = void 0;
|
|
6
|
+
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"));
|
|
@@ -34,24 +34,28 @@ const trimTrailingSlash = (p) => {
|
|
|
34
34
|
}
|
|
35
35
|
return p;
|
|
36
36
|
};
|
|
37
|
+
const getConfig = (outDir, entryPoint, onProgressUpdate, options) => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return (0, webpack_config_1.webpackConfig)({
|
|
40
|
+
entry,
|
|
41
|
+
userDefinedComponent: entryPoint,
|
|
42
|
+
outDir,
|
|
43
|
+
environment: 'production',
|
|
44
|
+
webpackOverride: (_a = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _a !== void 0 ? _a : remotion_1.Internals.defaultOverrideFunction,
|
|
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,
|
|
47
|
+
maxTimelineTracks: 15,
|
|
48
|
+
// For production, the variables are set dynamically
|
|
49
|
+
envVariables: {},
|
|
50
|
+
entryPoints: [],
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.getConfig = getConfig;
|
|
37
54
|
const bundle = async (entryPoint, onProgressUpdate, options) => {
|
|
38
|
-
var _a, _b
|
|
55
|
+
var _a, _b;
|
|
39
56
|
const outDir = await prepareOutDir((_a = options === null || options === void 0 ? void 0 : options.outDir) !== null && _a !== void 0 ? _a : null);
|
|
40
|
-
const
|
|
41
|
-
|
|
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
|
-
entryPoints: [],
|
|
53
|
-
}),
|
|
54
|
-
]);
|
|
57
|
+
const [, config] = (0, exports.getConfig)(outDir, entryPoint, onProgressUpdate, options);
|
|
58
|
+
const output = await promisified([config]);
|
|
55
59
|
if (!output) {
|
|
56
60
|
throw new Error('Expected webpack output');
|
|
57
61
|
}
|
|
@@ -59,7 +63,7 @@ const bundle = async (entryPoint, onProgressUpdate, options) => {
|
|
|
59
63
|
if (errors !== undefined && errors.length > 0) {
|
|
60
64
|
throw new Error(errors[0].message + '\n' + errors[0].details);
|
|
61
65
|
}
|
|
62
|
-
const baseDir = (
|
|
66
|
+
const baseDir = (_b = options === null || options === void 0 ? void 0 : options.publicPath) !== null && _b !== void 0 ? _b : '/';
|
|
63
67
|
const publicDir = '/' +
|
|
64
68
|
[trimTrailingSlash(trimLeadingSlash(baseDir)), 'public']
|
|
65
69
|
.filter(Boolean)
|
package/dist/index.d.ts
CHANGED
|
@@ -13,10 +13,16 @@ export declare const BundlerInternals: {
|
|
|
13
13
|
envVariables: Record<string, string>;
|
|
14
14
|
maxTimelineTracks: number;
|
|
15
15
|
entryPoints: string[];
|
|
16
|
-
}) => webpack.Configuration;
|
|
16
|
+
}) => [string, webpack.Configuration];
|
|
17
17
|
indexHtml: (staticHash: string, baseDir: string, editorName: string | null, inputProps: object | null) => string;
|
|
18
|
-
cacheExists: (environment: "development" | "production") =>
|
|
19
|
-
clearCache: (
|
|
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];
|
|
20
26
|
};
|
|
21
27
|
export { bundle } from './bundle';
|
|
22
28
|
export { webpack };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.webpack = exports.bundle = exports.BundlerInternals = void 0;
|
|
4
|
+
const bundle_1 = require("./bundle");
|
|
4
5
|
const index_html_1 = require("./index-html");
|
|
5
6
|
const webpack_cache_1 = require("./webpack-cache");
|
|
6
7
|
const webpack_config_1 = require("./webpack-config");
|
|
@@ -13,6 +14,7 @@ exports.BundlerInternals = {
|
|
|
13
14
|
indexHtml: index_html_1.indexHtml,
|
|
14
15
|
cacheExists: webpack_cache_1.cacheExists,
|
|
15
16
|
clearCache: webpack_cache_1.clearCache,
|
|
17
|
+
getConfig: bundle_1.getConfig,
|
|
16
18
|
};
|
|
17
|
-
var
|
|
18
|
-
Object.defineProperty(exports, "bundle", { enumerable: true, get: function () { return
|
|
19
|
+
var bundle_2 = require("./bundle");
|
|
20
|
+
Object.defineProperty(exports, "bundle", { enumerable: true, get: function () { return bundle_2.bundle; } });
|
package/dist/webpack-cache.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare type Environment = 'development' | 'production';
|
|
2
|
+
declare type CacheState = 'exists' | 'other-exists' | 'does-not-exist';
|
|
2
3
|
declare global {
|
|
3
4
|
namespace NodeJS {
|
|
4
5
|
interface ProcessVersions {
|
|
@@ -6,7 +7,7 @@ declare global {
|
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
|
-
export declare const clearCache: (
|
|
10
|
-
export declare const getWebpackCacheName: (environment: Environment) => string;
|
|
11
|
-
export declare const cacheExists: (environment: Environment) =>
|
|
10
|
+
export declare const clearCache: () => Promise<void>;
|
|
11
|
+
export declare const getWebpackCacheName: (environment: Environment, hash: string) => string;
|
|
12
|
+
export declare const cacheExists: (environment: Environment, hash: string) => CacheState;
|
|
12
13
|
export {};
|
package/dist/webpack-cache.js
CHANGED
|
@@ -37,26 +37,47 @@ const getWebpackCacheDir = () => {
|
|
|
37
37
|
}
|
|
38
38
|
return path_1.default.resolve(dir, 'node_modules/.cache/webpack');
|
|
39
39
|
};
|
|
40
|
-
const remotionCacheLocation = (environment) => {
|
|
41
|
-
return path_1.default.join(getWebpackCacheDir(), (0, exports.getWebpackCacheName)(environment));
|
|
40
|
+
const remotionCacheLocation = (environment, hash) => {
|
|
41
|
+
return path_1.default.join(getWebpackCacheDir(), (0, exports.getWebpackCacheName)(environment, hash));
|
|
42
42
|
};
|
|
43
|
-
const clearCache = (
|
|
43
|
+
const clearCache = () => {
|
|
44
44
|
var _a;
|
|
45
|
-
return ((_a = fs_1.default.promises.rm) !== null && _a !== void 0 ? _a : fs_1.default.promises.rmdir)(
|
|
45
|
+
return ((_a = fs_1.default.promises.rm) !== null && _a !== void 0 ? _a : fs_1.default.promises.rmdir)(getWebpackCacheDir(), {
|
|
46
46
|
recursive: true,
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
49
|
exports.clearCache = clearCache;
|
|
50
|
-
const
|
|
50
|
+
const getPrefix = (environment) => {
|
|
51
|
+
return `remotion-v4-${environment}`;
|
|
52
|
+
};
|
|
53
|
+
const getWebpackCacheName = (environment, hash) => {
|
|
51
54
|
if (environment === 'development') {
|
|
52
|
-
return
|
|
55
|
+
return `${getPrefix(environment)}-${hash}`;
|
|
53
56
|
}
|
|
54
57
|
// In production, the cache is independent from input props because
|
|
55
58
|
// they are passed over URL params. Speed is mostly important in production.
|
|
56
|
-
return
|
|
59
|
+
return `${getPrefix(environment)}-${hash}`;
|
|
57
60
|
};
|
|
58
61
|
exports.getWebpackCacheName = getWebpackCacheName;
|
|
59
|
-
const
|
|
60
|
-
|
|
62
|
+
const hasOtherCache = (environment) => {
|
|
63
|
+
const cacheDir = fs_1.default.readdirSync(getWebpackCacheDir());
|
|
64
|
+
if (cacheDir.find((c) => {
|
|
65
|
+
return c.startsWith(getPrefix(environment));
|
|
66
|
+
})) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
};
|
|
71
|
+
const cacheExists = (environment, hash) => {
|
|
72
|
+
if (fs_1.default.existsSync(remotionCacheLocation(environment, hash))) {
|
|
73
|
+
return 'exists';
|
|
74
|
+
}
|
|
75
|
+
if (!fs_1.default.existsSync(getWebpackCacheDir())) {
|
|
76
|
+
return 'does-not-exist';
|
|
77
|
+
}
|
|
78
|
+
if (hasOtherCache(environment)) {
|
|
79
|
+
return 'other-exists';
|
|
80
|
+
}
|
|
81
|
+
return 'does-not-exist';
|
|
61
82
|
};
|
|
62
83
|
exports.cacheExists = cacheExists;
|
package/dist/webpack-config.d.ts
CHANGED
package/dist/webpack-config.js
CHANGED
|
@@ -27,6 +27,7 @@ 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
31
|
const react_dom_1 = __importDefault(require("react-dom"));
|
|
31
32
|
const remotion_1 = require("remotion");
|
|
32
33
|
const webpack_1 = __importStar(require("webpack"));
|
|
@@ -50,7 +51,7 @@ function truthy(value) {
|
|
|
50
51
|
return Boolean(value);
|
|
51
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
|
-
|
|
54
|
+
const conf = webpackOverride({
|
|
54
55
|
optimization: {
|
|
55
56
|
minimize: false,
|
|
56
57
|
},
|
|
@@ -65,12 +66,6 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
|
|
|
65
66
|
aggregateTimeout: 0,
|
|
66
67
|
ignored: ['**/.git/**', '**/node_modules/**'],
|
|
67
68
|
},
|
|
68
|
-
cache: enableCaching
|
|
69
|
-
? {
|
|
70
|
-
type: 'filesystem',
|
|
71
|
-
name: (0, webpack_cache_1.getWebpackCacheName)(environment),
|
|
72
|
-
}
|
|
73
|
-
: false,
|
|
74
69
|
devtool: environment === 'development'
|
|
75
70
|
? 'cheap-module-source-map'
|
|
76
71
|
: 'cheap-module-source-map',
|
|
@@ -108,7 +103,6 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
|
|
|
108
103
|
hashFunction: 'xxhash64',
|
|
109
104
|
globalObject: 'this',
|
|
110
105
|
filename: 'bundle.js',
|
|
111
|
-
path: outDir,
|
|
112
106
|
devtoolModuleFilenameTemplate: '[resource-path]',
|
|
113
107
|
assetModuleFilename: environment === 'development' ? '[path][name][ext]' : '[hash][ext]',
|
|
114
108
|
},
|
|
@@ -173,5 +167,23 @@ const webpackConfig = ({ entry, userDefinedComponent, outDir, environment, webpa
|
|
|
173
167
|
],
|
|
174
168
|
},
|
|
175
169
|
});
|
|
170
|
+
const hash = (0, crypto_1.createHash)('md5').update(JSON.stringify(conf)).digest('hex');
|
|
171
|
+
return [
|
|
172
|
+
hash,
|
|
173
|
+
{
|
|
174
|
+
...conf,
|
|
175
|
+
cache: enableCaching
|
|
176
|
+
? {
|
|
177
|
+
type: 'filesystem',
|
|
178
|
+
name: (0, webpack_cache_1.getWebpackCacheName)(environment, hash),
|
|
179
|
+
version: hash,
|
|
180
|
+
}
|
|
181
|
+
: false,
|
|
182
|
+
output: {
|
|
183
|
+
...conf.output,
|
|
184
|
+
path: outDir,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
];
|
|
176
188
|
};
|
|
177
189
|
exports.webpackConfig = webpackConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/bundler",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
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.
|
|
29
|
+
"remotion": "3.1.5",
|
|
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": "
|
|
66
|
+
"gitHead": "965ca68bd4efce9ca5e27fe30c4a31aec594575c"
|
|
67
67
|
}
|