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

How to deal with file input? #3

Closed
parroit opened this issue Jul 28, 2014 · 3 comments
Closed

How to deal with file input? #3

parroit opened this issue Jul 28, 2014 · 3 comments
Labels

Comments

@parroit
Copy link
Owner

parroit commented Jul 28, 2014

pure-cjs input option is currently overwritten with what come from gulp pipeline
(typically from a gulp.src call).
This is somewhat a waste of resource, because input file is read by gulp and then from
pure-cjs.

We could instead use the provided input option, and make this plugin a substitution of
gulp.src

@RReverser
Copy link

First of all, this should be created as question in pure-cjs repo not this plugin's - so other users could easily track it.

Anyway.

On one hand, it's not just a waste of resource, but also can be a real problem since other Gulp plugins could have transformed original JS files before gulp-pure-cjs, and pure-cjs will re-read them from file system. This should be probably added as a caveat to README for now (i.e. "use gulp-pure-cjs as first plugin in your transformation chain").

On another hand, it requires rewriting part of pure-cjs in pretty different way that looks for files not in file system but in some array of vinyl File objects or similar. I'm not sure if that will be done soon, as I'll rather create corresponding CommonJS plugin for aster that will operate pretty much the same, but will allow chaining with other AST transformation plugins and already has plugins for integration with Grunt and Gulp.

@parroit
Copy link
Owner Author

parroit commented Jul 29, 2014

I agree, I looked at the part of pure-cjs where files are read from disk, and it appear not so easy to change it to read from vinyl File objects.

An idea could be to make the gulp plugin act as a replace of gulp.src, instead of a "through" plugin,
but maybe this interfere with other gulp standard mechanism (e.g. sourcemaps generation).

Some code to better explain the idea...

the plugin is actually used like this:

gulp.src('./lib/index.js')
    .pipe(pure({
        exports: 'my-exported-module'
    }))
    .pipe(gulp.dest('dist'));

the plugin will be instead used like this:

    pure({
        input: './lib/index.js',
        exports: 'my-exported-module'
    }))
    .pipe(gulp.dest('dist'));

@parroit
Copy link
Owner Author

parroit commented Jul 29, 2014

I added a section in README with a warning

@parroit parroit closed this as completed Jul 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants