Skip to content

wasm build with: EXPORT_NAME not used in shell,  #20801

@simonbuehler

Description

@simonbuehler

hi,

when building opencv.js with MODULARIZE=1 -s EXPORT_NAME="'cv'" around the line

var Module = globalThis.Module || (typeof {{{ EXPORT_NAME }}} != 'undefined' ? {{{ EXPORT_NAME }}} : {});

the final code is this:

  var cv = (() => {
    var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
    if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
    return (
      function (moduleArg = {}) {

        var Module = moduleArg;
        var cv = Module; <-- this is missing to make the code in e.g. Module[imread] work (which uses cv.somemethod)

        var readyPromiseResolve, readyPromiseReject; Module["ready"] = new....

so the Module is set but should be named EXPORT_NAME ( cv in this case) ?

i always have to add the var cv = Module line in the generated code, how can this be fixed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions