Skip to content

Commit 13cafce

Browse files
committed
Making all modes of importing all work the same
Importing with ES5 or ES6, with default import or `* as`, now all do the same thing. Thanks to @longnguyen2004 for pushing this in the right direction. Should fix #66.
1 parent de14f6f commit 13cafce

File tree

6 files changed

+736
-722
lines changed

6 files changed

+736
-722
lines changed

Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -895,13 +895,16 @@ dist/libav-$(LIBAVJS_VERSION)-%.dbg.thr.mjs: build/ffmpeg-$(FFMPEG_VERSION)/buil
895895
rmdir $(@).d
896896

897897

898-
build/libav-$(LIBAVJS_VERSION).js: libav.in.js post.in.js funcs.json tools/apply-funcs.js
898+
build/libav-$(LIBAVJS_VERSION).js: libav.in.js libav.types.in.d.ts post.in.js funcs.json tools/apply-funcs.js
899899
mkdir -p build dist
900900
./tools/apply-funcs.js $(LIBAVJS_VERSION)
901901

902-
build/libav.types.d.ts build/libav-$(LIBAVJS_VERSION).mjs build/exports.json build/post.js: build/libav-$(LIBAVJS_VERSION).js
902+
build/libav.types.d.ts build/libav-$(LIBAVJS_VERSION).in.mjs build/exports.json build/post.js: build/libav-$(LIBAVJS_VERSION).js
903903
touch $@
904904

905+
build/libav-$(LIBAVJS_VERSION).mjs: build/libav-$(LIBAVJS_VERSION).in.mjs
906+
./tools/mk-es6.js ../build/libav-$(LIBAVJS_VERSION).js $< > $@
907+
905908
node_modules/.bin/terser:
906909
npm install
907910

Makefile.m4

+5-2
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,16 @@ buildrule(thr, [[[]]], thr, [[[$(ES6FLAGS) $(THRFLAGS) -sPTHREAD_POOL_SIZE=navig
155155
buildrule(thr, dbg., thr, [[[-gsource-map $(THRFLAGS) -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency]]], js)
156156
buildrule(thr, dbg., thr, [[[-gsource-map $(ES6FLAGS) $(THRFLAGS) -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency]]], mjs)
157157

158-
build/libav-$(LIBAVJS_VERSION).js: libav.in.js post.in.js funcs.json tools/apply-funcs.js
158+
build/libav-$(LIBAVJS_VERSION).js: libav.in.js libav.types.in.d.ts post.in.js funcs.json tools/apply-funcs.js
159159
mkdir -p build dist
160160
./tools/apply-funcs.js $(LIBAVJS_VERSION)
161161

162-
build/libav.types.d.ts build/libav-$(LIBAVJS_VERSION).mjs build/exports.json build/post.js: build/libav-$(LIBAVJS_VERSION).js
162+
build/libav.types.d.ts build/libav-$(LIBAVJS_VERSION).in.mjs build/exports.json build/post.js: build/libav-$(LIBAVJS_VERSION).js
163163
touch $@
164164

165+
build/libav-$(LIBAVJS_VERSION).mjs: build/libav-$(LIBAVJS_VERSION).in.mjs
166+
./tools/mk-es6.js ../build/libav-$(LIBAVJS_VERSION).js $< > $@
167+
165168
node_modules/.bin/terser:
166169
npm install
167170

libav.in.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414
*/
1515

16-
@E6 let LibAV;
16+
@E6 const libav = {};
1717

1818
(function() {
1919
function isWebAssemblySupported(module) {
@@ -38,13 +38,13 @@
3838
return false;
3939
}
4040

41-
var libav;
41+
@E5 var libav;
4242
var nodejs = (typeof process !== "undefined");
4343

44-
// Make sure LibAV is defined for later loading
45-
if (typeof LibAV === "undefined")
46-
LibAV = {};
47-
libav = LibAV;
44+
@E5 // Make sure LibAV is defined for later loading
45+
@E5 if (typeof LibAV === "undefined")
46+
@E5 LibAV = {};
47+
@E5 libav = LibAV;
4848

4949
if (!libav.base) {
5050
@E6 libav.base = import.meta.url;
@@ -577,10 +577,11 @@
577577
});
578578
}
579579

580-
@E5 if (nodejs) {
581-
@E5 libav.default = libav;
580+
@E5 if (nodejs)
582581
@E5 module.exports = libav;
583-
@E5 }
584582
})();
585583

586-
@E6 export default LibAV;
584+
@E6 export const {
585+
@E6 @EXPORTS
586+
@E6 } = libav;
587+
@E6 export default libav;

0 commit comments

Comments
 (0)