Skip to content

[Bug]: No export when export function with eval usage #476

@Timeless0911

Description

@Timeless0911
Contributor

Before

Source

export function add(a: number, b: number) {
  return a + b;
}

Output

function add(a, b) {
    return a + b;
}
export { add };

Current

If we use eval in a function

Source

export function add(a: number, b: number) {
  return a + b;
}

export function evalFunc() {
  return eval('1');
}

Output

// The require scope
var __webpack_require__ = {};
/************************************************************************/ // webpack/runtime/define_property_getters
(()=>{
    __webpack_require__.d = function(exports, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
// webpack/runtime/has_own_property
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
// webpack/runtime/make_namespace_object
(()=>{
    // define __esModule on exports
    __webpack_require__.r = function(exports) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports, '__esModule', {
            value: true
        });
    };
})();
/************************************************************************/ var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    add: function() {
        return add;
    },
    evalFunc: function() {
        return evalFunc;
    }
});
function add(a, b) {
    return a + b;
}
function evalFunc() {
    return eval('1');
}

Activity

self-assigned this
on Nov 25, 2024
fi3ework

fi3ework commented on Nov 27, 2024

@fi3ework
Member

Currently, entry module is required to be concatenated, eval will break the premise.

added this to the 1.0 milestone on May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

RspackRspack related issue🐞 bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @fi3ework@Timeless0911

      Issue actions

        [Bug]: No export when export function with eval usage · Issue #476 · web-infra-dev/rslib