Skip to content

Update UMD Wrapper#33

Merged
jridgewell merged 2 commits into
mainfrom
umd
Jun 30, 2025
Merged

Update UMD Wrapper#33
jridgewell merged 2 commits into
mainfrom
umd

Conversation

@jridgewell

@jridgewell jridgewell commented Jun 30, 2025

Copy link
Copy Markdown
Owner

The old wrapper left require('foo') calls within the factory body and passed in different implementations of require depending on the environment. The new impl will extract all require calls to the factory header, allowing all require calls to be statically analyzed.

Before:

(function (global, factory, e, m) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(require, exports, module) :
    typeof define === 'function' && define.amd ? define(factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(function(spec) {
        return {"@jridgewell/sourcemap-codec": global.sourcemapCodec, "@jridgewell/trace-mapping": global.traceMapping}[spec];
    }, e = {}, m = { exports: e }), global.genMapping = m.exports);
})(this, (function (require, exports, module) {

var import_sourcemap_codec = require("@jridgewell/sourcemap-codec");
//...

After:

(function (global, factory, e, m) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, module, require('@jridgewell/sourcemap-codec'), require('@jridgewell/trace-mapping')) :
    typeof define === 'function' && define.amd ? define(['exports', 'module', '@jridgewell/sourcemap-codec', '@jridgewell/trace-mapping'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(e = {}, m = { exports: e }, global.sourcemapCodec, global.traceMapping), global.genMapping = 'default' in m.exports ? m.exports.default : m.exports);
})(this, (function (exports, module, require_sourcemapCodec, require_traceMapping) {

var import_sourcemap_codec = require_sourcemapCodec;

Fixes #31

The old wrapper left `require('foo')` calls within the factory body and passed in different implementations of `require` depending on the environment. The new impl will extract all require calls to the factory header, allowing all `require` calls to be statically analyzed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using the latest version still results in errors

1 participant