Skip to content

Bugs regarding local named AMD modules #202

Description

@dayyeung

Related: #153

  1. (Note the empty dependency array, the code works if it is omitted)
define("test", [], function() {
  return 1234;
});
define(["require", "test"], function(require, test) {
  test.should.be.eql(1234);
  require("test").should.be.eql(1234)
  return "exported"
});

currently compiles to:

var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_LOCAL_MODULE_0__;!(__WEBPACK_LOCAL_MODULE_0__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  return 1234;
}.apply(null, __WEBPACK_AMD_DEFINE_ARRAY__)));
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, __WEBPACK_LOCAL_MODULE_0__], __WEBPACK_AMD_DEFINE_RESULT__ = (function(require, test) {
  test.should.be.eql(1234);
  require("test").should.be.eql(1234)
  return "exported"
}.apply(null, __WEBPACK_AMD_DEFINE_ARRAY__)), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1. I am quite sure that currently, doing require("test") as above does not work, even in your original example?

  2. (Not sure if you intended to support this but I am reporting anyway)

define("dep", function(){
  return 5678;
});
define("test", ["dep"], function() {
  return 1234;
});
define(["require", "test"], function(require, test) {
  test.should.be.eql(1234);
  require("test").should.be.eql(1234)
  return "exported"
});

currently compiles to:

var __WEBPACK_LOCAL_MODULE_0__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_LOCAL_MODULE_1__;!(__WEBPACK_LOCAL_MODULE_0__ = (function(){
  return 5678;
}.call(exports, __webpack_require__, exports, module)));
!(__WEBPACK_LOCAL_MODULE_1__ = [__WEBPACK_LOCAL_MODULE_0__], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  return 1234;
}.apply(null, __WEBPACK_AMD_DEFINE_ARRAY__)));
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__, __WEBPACK_LOCAL_MODULE_1__], __WEBPACK_AMD_DEFINE_RESULT__ = (function(require, test) {
  test.should.be.eql(1234);
  require("test").should.be.eql(1234)
  return "exported"
}.apply(null, __WEBPACK_AMD_DEFINE_ARRAY__)), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions