Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack (6to5) require/import problem #86

Closed
max-mykhailenko opened this issue Feb 16, 2015 · 10 comments
Closed

webpack (6to5) require/import problem #86

max-mykhailenko opened this issue Feb 16, 2015 · 10 comments

Comments

@max-mykhailenko
Copy link

I tried to use autolinker from npm module

And after import
import Autolinker from 'autolinker';

get this
Uncaught TypeError: Cannot set property 'returnExportsGlobal' of undefined

In code

(function (root, factory) {
    if (true) {
        // AMD. Register as an anonymous module.
        !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () {
            return root.returnExportsGlobal = factory();
        }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
    } else if (typeof exports === "object") {
        // Node. Does not work with strict CommonJS, but
        // only CommonJS-like enviroments that support module.exports,
        // like Node.
        module.exports = factory();
    } else {
        root.Autolinker = factory();
    }
})(undefined, function () {                // why this undefined?
... // autolinker here
@max-mykhailenko
Copy link
Author

if I changed https://github.com/gregjacobs/Autolinker.js/blob/master/dist/Autolinker.js#L2
to if (root && typeof define === 'function' && define.amd) {
all works fine.

@max-mykhailenko
Copy link
Author

Where I can change it in forked version?

@iam4x
Copy link

iam4x commented Mar 10, 2015

bump! need this!

@gregjacobs
Copy link
Owner

Hey guys, sorry for the late reply. Not sure exactly what you're doing here though. What do you have installed to give you that import statement?

@max-mykhailenko
Copy link
Author

import or require provided by babel and webpack

@LeZuse
Copy link

LeZuse commented May 31, 2015

Just used this to fix the issue with Webpack import and it works flawlessly.

LeZuse added a commit to LeZuse/Autolinker.js that referenced this issue Jun 23, 2015
@MadLittleMods
Copy link

👍 I am also running into this webpack issue. The solution proposed by @max-mykhailenko works but I assume messes with other environments.

lencioni added a commit to lencioni/github-issues-react-relay that referenced this issue Aug 24, 2015
Issue bodies are in markdown format, so I brought in a markdown parser.
Before landing on marked, I tried remarkable [0] but that didn't work
out so well with webpack due to an issue in one of its dependencies
(Autolinker.js [1]). Next, I tried markdown-js [2] which seemed okay,
but it doesn't seem to have support for fenced code blocks or GitHub
flavored markdown [3], which I'd really like to have for this project
since I need to render markdown that comes from GitHub's API. marked
seems to support this better and it doesn't have problems with webpack.

[0]: https://github.com/jonschlinkert/remarkable
[1]: gregjacobs/Autolinker.js#86
[2]: https://github.com/evilstreak/markdown-js
[3]: evilstreak/markdown-js#41
@LeZuse
Copy link

LeZuse commented Mar 29, 2016

Are you guys also using Babel? I think what we are running into here is Babel strict mode. It is turned off by default in Babel 6. See http://stackoverflow.com/a/33821820/303016

@prashanth1509
Copy link

{ test: /.js$/, loader: 'imports?define=>false'} should fix it.

@gregjacobs
Copy link
Owner

Not sure if anyone is still having an issue with this 3 years later, but feel free to reopen if needed 😄

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

No branches or pull requests

6 participants