Giter Club home page Giter Club logo

gulp-iife's People

Contributors

adboomlodestar avatar dependabot[bot] avatar fvictorio avatar mariusschulz avatar phette23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gulp-iife's Issues

Cannot find module 'gulp-iife'

Hi,

I am running Node 5.0.0 and NPM 3.3.6.

$ gulp
module.js:339
    throw err;
    ^

Error: Cannot find module 'gulp-iife'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/ilovecoffe/test/gulpfile.js:9:13)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)

rendering for args option

I tried to use the args option. It just adds (function(){ ...})(arg1, arg2); I expected (function(arg1, arg2){ ...})(arg1, arg2);.

The second issue is that I have to declare global variables first ( to use window, document or undefined I have to write the following first var window = window)m before I can use them in the args array

Remove IIFE Before Adding

Is there any way to programmatically detect that there is already an IIFE? Our codebase already uses IIFEs, but I am thinking about using gulp-iife instead. I am worried about the performance implications of using 2 IIFEs, though I haven't done any performance tests. It's a big codebase, so I have to think there would be at least some performance loss, though this may be dwarfed by our use of angular, among other things.

One of our applications already uses gulp-iife, and it seems to work fine. The only issue is that we do not concatenate with gulp-iife in development, meaning things like an accidental global this causes problems in production but not development, but that is on us. Anyway, great job!

If there is no (easy) way to programmatically detect that there is an IIFE, or if you have to use acorn or something like that, please ignore and close this issue. If there is a way, could you look into supporting this? I would be fine with it being an optional option.

Apply it only to part of the sources?

I'm using a gulp task to combine and minify js files.
Some of those files belong to vendor libraries. Others are my own code.

I only want to add the iife to my won code. How can I do this without having to generate two temporal files that I combine later on?

suggestion for improvement

// guards against the function becoming an argument when two files with IIFEs are concatenated
;(function() {
...
})();

Exporting global names improvement

Hi Marius, I'd like to suggest you one new feature for your plugin. Sometimes it is needed to have one or more names (variables or functions) from the original code to be exported as globals. For example:

var a = 'some private stuff';
var b = 'some other private stuff';

// this is my object I would like to be globally accessible after wrapping into IIFE
function MyObject(params)
{
  // here I'm using a, b and other private members
  ...    
}

I would want this code after processing:

(function(context, globals) {
  var a = 'some private stuff';
  var b = 'some other private stuff';

  // this is my object I would like to be globally accessible after wrapping into IIFE
  function MyObject(params)
  {
    // here I'm using a, b and other private members
    ...    
  }

  // section to export global names
  for(var i = 0; i < globals.length; i++)
    context[globals[i]] = eval(globals[i]);

})(window, ['MyObject']);

where context and globals are both specified in plugin's config. context is global namespace usually window, globals is just an array of existing var/function names we want to be accessible at global level. eval is used to specify var/function by string name inside IIFE (it seems like this is the only way to access local name inside IIFE).

What do you think?

Publish lodash fix to NPM

Hey! How are you?

I came to to try to contribute into updating lodash version and I checked out you already did it.
Would you mind to publish this new version?

I runned the tests and everything sound ok. Is something needed? I Please, let me know If I can help somehow.

Thanks for your work.

Does not work properly when working with subfolders

Hi,

Directory Structure:

app/
  |__images/
  |__scripts/
     |__adapters/
        |__adapter_one.js
        |__adapter_two.js
        |__ ...
     |__models/
        |__model_one.js
        |__model_two.js
        |__ ...
     |__ ...
  |__app.js

Gulp Task:

gulp.task('iife', function() {
  return gulp.src('app/scripts/**/*')
  .pipe(iife({ useStrict: false }))
  .pipe(gulp.dest('app/test/'));
});

Running above task gives you following error:

$ gulp iife
[18:01:55] Using gulpfile /Users/ilovecoffee/app/gulpfile.js
[18:01:55] Starting 'iife'...
[18:01:55] 'iife' errored after 96 ms
[18:01:55] Error: EEXIST: file already exists, mkdir '/Users/ilovecoffee/app/test/adapters'
    at Error (native)

What is strange is that iife creates test folder with adapter file. The content of this adapter file is:

// adapter.js
;(function() {
null
}());

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.