Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

context is undefined when this module gets bundled using Babel 6 #374

Open
mig8447 opened this issue Aug 8, 2020 · 2 comments
Open

context is undefined when this module gets bundled using Babel 6 #374

mig8447 opened this issue Aug 8, 2020 · 2 comments

Comments

@mig8447
Copy link

mig8447 commented Aug 8, 2020

The Module header needs to account for context being undefined. By default Babel 6 replaces this with undefined.

Problem is that the header in the Grunt file does not account for this and therefore when this file gets bundled with others and passed through Babel 6, it doesn't work.

The line in the link below needs to change to accomodate something like the following:

(function(global, factory) {
    (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define('Firepad', factory) : (global = global || self,
    global.Firepad = factory());
})(this, function(){ ... });

' else if (typeof context[\'define\'] == \'function\' && context[\'define\'][\'amd\']) define(definition);',

@mig8447 mig8447 changed the title context is undefined when this module gets packaged using Babel 6 context is undefined when this module gets packaged using Babel 6 Aug 8, 2020
@mig8447 mig8447 changed the title context is undefined when this module gets packaged using Babel 6 context is undefined when this module gets bundled using Babel 6 Aug 8, 2020
@samtstern
Copy link
Contributor

@mig8447 thanks for reporting this! I don't know nearly enough about Babel 6 / Grunt to know what the fix should look like here. Do you want to submit a Pull Request with a fix? If so please include some instructions for me to reproduce the issue.

@mig8447
Copy link
Author

mig8447 commented Aug 12, 2020

@samstern, I got the fix on https://github.com/mig8447/firepad/blob/master/Gruntfile.js, this is not only for Babel 6 but also works to fix some bundling issues with other libraries.

The change is basically making the context variable to take the value of self if it is undefined.

BTW: I ran the Grunt default task and both build and test tasks are passing ok

I don't have much time available to go through the PR process right now but you can take the fix from the link above and merge it if you may

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants