Skip to content

Commit 6dd5284

Browse files
committed
Switched from CommonJS exports to ESM exports
1 parent 174a0f9 commit 6dd5284

File tree

7 files changed

+23
-19
lines changed

7 files changed

+23
-19
lines changed

ffmpeg-ffmpeg-0.10.2.tgz

73.7 KB
Binary file not shown.

scripts/server.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ const webpackConfig = require('./webpack.config.dev');
88
const compiler = webpack(webpackConfig);
99
const app = express();
1010

11+
function coi(req, res, next) {
12+
res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
13+
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
14+
next();
15+
}
16+
1117
app.use(cors());
18+
app.use(coi);
19+
1220
app.use('/', express.static(path.resolve(__dirname, '..')));
1321
app.use(middleware(compiler, { publicPath: '/dist', writeToDisk: true }));
1422

src/browser/defaultOptions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ const { devDependencies } = require('../../package.json');
33
/*
44
* Default options for browser environment
55
*/
6-
module.exports = {
7-
corePath: typeof process !== 'undefined' && process.env.NODE_ENV === 'development'
6+
const corePath = typeof process !== 'undefined' && process.env.NODE_ENV === 'development'
87
? new URL('/node_modules/@ffmpeg/core/dist/ffmpeg-core.js', import.meta.url).href
9-
: `https://unpkg.com/@ffmpeg/core@${devDependencies['@ffmpeg/core'].substring(1)}/dist/ffmpeg-core.js`,
10-
};
8+
: `https://unpkg.com/@ffmpeg/core@${devDependencies['@ffmpeg/core'].substring(1)}/dist/ffmpeg-core.js`
9+
10+
export {corePath};

src/browser/fetchFile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const readFromBlobOrFile = (blob) => (
1111
})
1212
);
1313

14-
module.exports = async (_data) => {
14+
export const fetchFile = async (_data) => {
1515
let data = _data;
1616
if (typeof _data === 'undefined') {
1717
return new Uint8Array();

src/browser/getCreateFFmpegCore.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const toBlobURL = async (url, mimeType) => {
1818
return blobURL;
1919
};
2020

21-
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
21+
export const getCreateFFmpegCore = async ({ corePath: _corePath }) => {
2222
// in Web Worker context
23-
module.exports = async ({ corePath: _corePath }) => {
23+
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
2424
if (typeof _corePath !== 'string') {
2525
throw Error('corePath should be a string!');
2626
}
@@ -59,9 +59,7 @@ if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScop
5959
wasmPath,
6060
workerPath,
6161
});
62-
};
63-
} else {
64-
module.exports = async ({ corePath: _corePath }) => {
62+
} else {
6563
if (typeof _corePath !== 'string') {
6664
throw Error('corePath should be a string!');
6765
}
@@ -107,6 +105,8 @@ if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScop
107105
wasmPath,
108106
workerPath,
109107
});
110-
};
108+
}
109+
111110
}
112111

112+

src/browser/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
const defaultOptions = require('./defaultOptions');
2-
const getCreateFFmpegCore = require('./getCreateFFmpegCore');
3-
const fetchFile = require('./fetchFile');
2+
const {getCreateFFmpegCore} = require('./getCreateFFmpegCore');
3+
const {fetchFile} = require('./fetchFile');
44

5-
module.exports = {
6-
defaultOptions,
7-
getCreateFFmpegCore,
8-
fetchFile,
9-
};
5+
export {defaultOptions, getCreateFFmpegCore, fetchFile};

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require('regenerator-runtime/runtime');
22
const createFFmpeg = require('./createFFmpeg');
33
const { fetchFile } = require('./node');
44

5-
module.exports = {
5+
export {
66
/*
77
* Create ffmpeg instance.
88
* Each ffmpeg instance owns an isolated MEMFS and works

0 commit comments

Comments
 (0)