Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Request: support for files as well as directories in createPackage #8

Open
laurie71 opened this issue Feb 23, 2011 · 7 comments
Open

Comments

@laurie71
Copy link

I'd like to be able to createPackage({ paths: ['path/to/file.js']}) so that I can export sub-modules individually; it's not always appropriate/desirable to export all the files in a given directory and at the moment my only option, assuming a third party module whose file structure I don't control, is to copy the files I do want to export into a separate directory.

@laurie71
Copy link
Author

I found my feet with CoffeeScript and had a go at implementing this, but quickly realized the problem: this currently fails as there's nothing for getRelativePath() to calculate relative to, which makes sense; this needs a higher level solution.

One possibility would be to allow the 'paths' config to be an array of string-or-object, where strings must be directories and objects might be something like

{ root: 'path/to/base/dir'
, files: [ 'file.js', 'subdir/file2.js', ... ]
}

Or, for greater flexibility, 'files' could 'includes'/'excludes' as an array of filenames and/or glob patterns.

Thoughts?

@sstephenson
Copy link
Owner

It should be possible to organize your files in such a way that all browser-dependent files live in one tree, and all other files live in another tree. In Node, for example, the require.paths array lets you add multiple trees to the load path.

@sstephenson
Copy link
Owner

Closing this for now, but feel free to reopen if you have a case where it's not possible to split your app up into multiple trees.

@laurie71
Copy link
Author

My main concern isn't the code I write, and which I can organize into separate trees; it's if the files that need to be split into separate trees live in a module I don't control.

For example, suppose I come across some module that has a collection of utility routines that I want to be able to use in code I'll share CS/SS. If that module has additional code/files that I don't want to bundle to the client, I have to copy the utility routines into my shared tree.

This is a real use-case -- something I'm doing today -- and currently file copying is the only thing I can do to get those third-party dependancies to the browser without including other files from the same source tree.

@josh josh reopened this Mar 31, 2011
@justmoon
Copy link

Having the same issue: My code require()s parse-js from UglifyJS, but I don't want the rest of of UglifyJS. So either I need to be able to specify a single file or, better yet, Stitch should notice the require('../vendor/UglifyJS/lib/parse-js') in my code and automatically include that file into the package.

@davidelias
Copy link

I'm having the same problem. I'm working on a mobile webapp and each user role has a different app/module. So for each role i don't want to merge all the files and each module will have shared javascript.
Maybe dynamically resolving dependencies will help on this issue too, but probably this falls out of stitch scope.

@ghost
Copy link

ghost commented Jan 12, 2012

I've also thought about resolving dependencies and I think, regexp for require("stuff") would be at least as good as asset-pipeline. So, ok, we can scan files, but then it would be nice to add them separately to stitch and if they would see each other as they are located on a disk, with single root somewhere, it would work fine. @laurie71's proposal looks good for me.

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

No branches or pull requests

5 participants