firepad icon indicating copy to clipboard operation
firepad copied to clipboard

context is undefined when this module gets bundled using Babel 6

Open mig8447 opened this issue 5 years ago • 2 comments

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(){ ... });

https://github.com/FirebaseExtended/firepad/blob/e374771e97395c8c9334b3693589ab1ddf0983f1/Gruntfile.js#L54

mig8447 avatar Aug 08 '20 19:08 mig8447

@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.

samtstern avatar Aug 10 '20 07:08 samtstern

@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

mig8447 avatar Aug 12 '20 12:08 mig8447