Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Independent build tasks dependent on the performed changed (build.dev) #851

Closed
mgechev opened this issue May 11, 2016 · 2 comments
Closed

Comments

@mgechev
Copy link
Owner

mgechev commented May 11, 2016

We already commented out the clearn.dev task so it might be appropriate to implement the following behavior for speeding-up the development build:

  • On change in an external template and/or style only copy them to the corresponding location inside of the dist/dev directory.
  • On change of inline template, inline style or TypeScript file, transpile them and move them to the corresponding location inside of dist/dev.

This way we will achieve some performance improvements, however, their impact should not be as dramatical as disabling type checking or using gulp-cache as described here.

Based on suggestion by @mpetkov #645.

// @ludohenin @NathanWalker @d3viant0ne

@mgechev mgechev changed the title Distingishable phases of the build pro Independent build tasks dependent on the performed changed (build.dev) May 11, 2016
@mgechev mgechev closed this as completed Sep 26, 2016
@mgechev
Copy link
Owner Author

mgechev commented Oct 3, 2016

Recently, while using the seed, I had to create a task which execution takes 5s. This is a lot for dev build since it blocks everything else. I thought what I can do and with the current stateless task management (which is great but a bit limiting) there was no right way to approach.

I was thinking that we can have a global state, which mutates in utils/seed/watch.ts. So for instance:

export function watch(taskname: string) {
  return function () {
    let paths:string[]=[
      join(Config.APP_SRC,'**')
    ].concat(Config.TEMP_FILES.map((p) => { return '!'+p; }));

    plugins.watch(paths, (e: any) => {
      Config.getPluginConfig('files-changed').push(e.path);
      runSequence(taskname, () => {
        Config.getPluginConfig('files-changed').length = 0;
        notifyLiveReload(e);
      });
    });
  };
}

Later in the individual tasks, based on the file type we can:

// build.js.dev
export = (done: any, filesChanged: string[]) => {
  if (anyOfTheFilesIsTs...) {
    return gulp.src(...)
           .pipe(ts())
           .pipe(gulp.dest(...));
  } else {
    done();
  }
};

What do you think? We can extend this even further by exporting not only a single function but a task object which processes only tasks of given type:

const task: ITask = {
  precondition(files: string[]) {
    // decide if it should be activated
  },
  processFiles: [/\.ts$/],
  run(done) {
    // ...
  }
};
type FileType = RegExp;

interface ITask {
  precondition(files: string[]);
  processFiles: FileType[];
  run(done: any): GulpStream | any;
}

@ludohenin @TheDonDope what do you think?

PS: Probably it'll be better to move the list of changed files outside pluginConfig because a user can override it by mistake.

PS2: It'll be better to move the filtering logic in the task runner in tasks_tools.ts.

PS3: By default given task will be executed in all cases.

@mgechev
Copy link
Owner Author

mgechev commented Oct 9, 2016

PR here #1443.

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

No branches or pull requests

1 participant