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

Watch symlinks for linked files, and update bundle on changes to linked packages #6

Open
NervosaX opened this issue Apr 14, 2016 · 3 comments

Comments

@NervosaX
Copy link
Contributor

This was something I really wanted personally, as it helps flow. I managed to make it work really simply by just using the same chokidar internals:

        const watcher = new JspmWatch({
            app: {
                input: 'src/index.js',
                output: 'dist/index.js',
                buildOptions: {
                    minify: false,
                    mangle: false,
                    sourceMaps: true
                }
            },
            batchDelay: 250
        });

        chokidar.watch("jspm_packages/local", {
            followSymlinks: true,
            ignoreInitial: true
        }).on("all", (event, path) => {
            watcher._processEvent(event, path);
        });

        watcher.start();

This is only a working solution for jspm 0.17 of course.

@NervosaX
Copy link
Contributor Author

NervosaX commented May 8, 2016

Note you can actually just watch the entire jspm_packages/ directory for changes. Sometimes you wish to link using:

npm link ~/path/to/project npm:project-name which does not place it in the /local folder

@fyodorvi
Copy link
Owner

fyodorvi commented May 8, 2016

I haven't tried 0.17 just yet, do all linked packages sit within jspm_packages/local folder? Currently, I'm filtering out jspm_packages modules, but I'm thinking of adding a flag or a setting to specify jspm packages watch exclusion mask. It's done for performance reasons, so we don't have chokidar watching thousands of files which are unlikely to change, only with jspm config change (which will trigger full rebuild).

@NervosaX
Copy link
Contributor Author

NervosaX commented May 9, 2016

So with the new linking system, it creates a symlink. If you do the following:

jspm link ~/path/to/project it will read the package.json, and add a symlink in the local folder with that name to the path supplied. Pretty straight forward, and it's a good way to work on packages that aren't yet published to npm.

However, if you supply an npm/github path afterwards, it symlinks over the project in the npm or github folder. So if I was using jspm-watch in my jspm project:

jspm link ~/js/jspm-watch npm:jspm-watch would symlink the ~/js/jspm-watch folder as jspm_packages/npm/[email protected]


As for performance, it so far seems to be running on the lowest common denominator quite well, a 6-7 year old thinkpad. Still, it would be nice to be more specific.

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

No branches or pull requests

2 participants