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

Error with UMD pattern #5

Closed
jmanuelrp opened this issue Aug 8, 2015 · 2 comments
Closed

Error with UMD pattern #5

jmanuelrp opened this issue Aug 8, 2015 · 2 comments

Comments

@jmanuelrp
Copy link

I get a wild error when I import the library with RequireJS, I see that evaluate require instead of define in the UMD pattern

if (typeof module !== 'undefined' && module.exports) {
    module.exports = fecha;
} else if (typeof require !== 'undefined' && require.amd) {
    define(function () {
        return fecha;
    });
} else {
    main.fecha = fecha;
}

...

define(['bower_components/fecha/fecha'], function(fecha) {
    typeof fecha === 'undefined'; // true
    typeof window.fecha === 'undefined'; // true
    window.fecha.parse('2015-01-01'); // it's works
    fecha.parse('2015-01-01'); // error
});

whit define instead of require

if (typeof module !== 'undefined' && module.exports) {
    module.exports = fecha;
} else if (typeof define !== 'undefined' && define.amd) {
    define(function () {
        return fecha;
    });
} else {
    main.fecha = fecha;
}

...

define(['bower_components/fecha/fecha'], function(fecha) {
    typeof fecha === 'undefined'; // false
    typeof window.fecha === 'undefined'; // true
    // window.fecha.parse('2015-01-01'); // error
    fecha.parse('2015-01-01'); // it's works
});
@taylorhakes
Copy link
Owner

Thanks for finding this bug. I have released a new version. 0.2.2 df9861f

@taylorhakes
Copy link
Owner

I am closing this issue. If it still is an issue, please reopen.

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

2 participants