Switched from CommonJS exports to ESM exports
This commit is contained in:
@@ -3,8 +3,8 @@ const { devDependencies } = require('../../package.json');
|
||||
/*
|
||||
* Default options for browser environment
|
||||
*/
|
||||
module.exports = {
|
||||
corePath: typeof process !== 'undefined' && process.env.NODE_ENV === 'development'
|
||||
const corePath = typeof process !== 'undefined' && process.env.NODE_ENV === 'development'
|
||||
? new URL('/node_modules/@ffmpeg/core/dist/ffmpeg-core.js', import.meta.url).href
|
||||
: `https://unpkg.com/@ffmpeg/core@${devDependencies['@ffmpeg/core'].substring(1)}/dist/ffmpeg-core.js`,
|
||||
};
|
||||
: `https://unpkg.com/@ffmpeg/core@${devDependencies['@ffmpeg/core'].substring(1)}/dist/ffmpeg-core.js`
|
||||
|
||||
export {corePath};
|
||||
|
||||
@@ -11,7 +11,7 @@ const readFromBlobOrFile = (blob) => (
|
||||
})
|
||||
);
|
||||
|
||||
module.exports = async (_data) => {
|
||||
export const fetchFile = async (_data) => {
|
||||
let data = _data;
|
||||
if (typeof _data === 'undefined') {
|
||||
return new Uint8Array();
|
||||
|
||||
@@ -18,9 +18,9 @@ const toBlobURL = async (url, mimeType) => {
|
||||
return blobURL;
|
||||
};
|
||||
|
||||
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
|
||||
export const getCreateFFmpegCore = async ({ corePath: _corePath }) => {
|
||||
// in Web Worker context
|
||||
module.exports = async ({ corePath: _corePath }) => {
|
||||
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
|
||||
if (typeof _corePath !== 'string') {
|
||||
throw Error('corePath should be a string!');
|
||||
}
|
||||
@@ -59,9 +59,7 @@ if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScop
|
||||
wasmPath,
|
||||
workerPath,
|
||||
});
|
||||
};
|
||||
} else {
|
||||
module.exports = async ({ corePath: _corePath }) => {
|
||||
} else {
|
||||
if (typeof _corePath !== 'string') {
|
||||
throw Error('corePath should be a string!');
|
||||
}
|
||||
@@ -107,6 +105,8 @@ if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScop
|
||||
wasmPath,
|
||||
workerPath,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
const defaultOptions = require('./defaultOptions');
|
||||
const getCreateFFmpegCore = require('./getCreateFFmpegCore');
|
||||
const fetchFile = require('./fetchFile');
|
||||
const {getCreateFFmpegCore} = require('./getCreateFFmpegCore');
|
||||
const {fetchFile} = require('./fetchFile');
|
||||
|
||||
module.exports = {
|
||||
defaultOptions,
|
||||
getCreateFFmpegCore,
|
||||
fetchFile,
|
||||
};
|
||||
export {defaultOptions, getCreateFFmpegCore, fetchFile};
|
||||
@@ -2,7 +2,7 @@ require('regenerator-runtime/runtime');
|
||||
const createFFmpeg = require('./createFFmpeg');
|
||||
const { fetchFile } = require('./node');
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
/*
|
||||
* Create ffmpeg instance.
|
||||
* Each ffmpeg instance owns an isolated MEMFS and works
|
||||
|
||||
Reference in New Issue
Block a user