Code Monkey home page Code Monkey logo

broccoli-source's Introduction

Broccoli Source

Build Status Build status

Broccoli plugin for creating "source" nodes that refer to physical file system directories.

Example Usage

In Brocfile.js:

const { WatchedDir, UnwatchedDir } = require('broccoli-source');

// Refers to the ./lib directory on disk, and watches it.
const lib = new WatchedDir('lib');
// Note: this is equivalent to the deprecated plain-string syntax:
// const lib = 'lib';

// Refers to the ./bower_components/jquery directory, but does not watch it.
const jquery = new UnwatchedDir('bower_components/jquery');

Reference

new WatchedDir(directoryPath, options)

Create a Broccoli node referring to a directory on disk. The Broccoli watcher used by broccoli serve will watch the directory and all subdirectories, and trigger a rebuild whenever something changes.

  • directoryPath: A path to a directory, either absolute, or relative to the working directory (typically the directory containing Brocfile.js).

    The directory must exist, or Broccoli will abort.

  • options:

    • annotation: A human-readable description for this node.

new UnwatchedDir(directoryPath, options)

Same as WatchedDir, but the directory will not be watched.

This can be useful for performance reasons. For example, say you want to refer to a large directory hierarchy of third-party code in your Brocfile.js. Such third-party code is rarely edited in practice. Using UnwatchedDir instead of WatchedDir saves the overhead of setting up useless file system watchers.

When in doubt, use WatchedDir instead.

broccoli-source's People

Contributors

dependabot[bot] avatar joliss avatar locks avatar rwjblue avatar stefanpenner avatar thoov avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

broccoli-source's Issues

Should transform paths into absolute paths.

Given any arbitrary input path in the working directory, we should expand relative paths to their absolute path.

Without this, any plugins must also use the same process.cwd() when reading from their own this.inputPaths.

TypeScript Setup is broken

There are a number of issues with the typescript setup of this repo:

  • cannot build twice (yarn build && yarn build fails)
  • jumping to definition ends up in tmp

The first one is massively more annoying...

way to access builtin watcher API

I found that side-effects in broccoli is quite hard, for example "live-reload" implementation, all we need - is get changed input files, but I can't find simple references to deal with it, all implementations trying to map input to output and it bring computing and FS overhead.

Adding custom watcher also seems not optimal, because broccoli already have builtin (for watched nodes).

TypeError: tree.cleanup is not a function

I tried a very basic example (see below) and reach a TypeError problem.

This is the file I used

var broccoliSource = require('broccoli-source');
var src = new broccoliSource.WatchedDir('src');

nothing more (I tried to reduce as much as possible to keep only what was necessary to still have the error).

And the error is the following.

TypeError: tree.cleanup is not a function
    at cleanupTree (/<project_path>/node_modules/broccoli/lib/builder.js:156:17)
    at /<project_path>/node_modules/broccoli/node_modules/promise-map-series/index.js:11:14
    at lib$rsvp$$internal$$tryCatch (/<project_path>/node_modules/broccoli/node_modules/rsvp/dist/rsvp.js:493:16)
    at lib$rsvp$$internal$$invokeCallback (/<project_path>/node_modules/broccoli/node_modules/rsvp/dist/rsvp.js:505:17)
    at /<project_path>/node_modules/broccoli/node_modules/rsvp/dist/rsvp.js:1001:13
    at lib$rsvp$asap$$flush (/<project_path>/node_modules/broccoli/node_modules/rsvp/dist/rsvp.js:1198:9)
    at doNTCallback0 (node.js:407:9)
    at process._tickCallback (node.js:336:13)
    at Function.Module.runMain (module.js:477:11)
    at startup (node.js:117:18)

Build failed

Note: I've replaced the project's path with <project_path>.

I'm running NodeJS v4.1.1 and have the following dependencies.

"devDependencies": {
  "broccoli": "^0.16.8",
  "broccoli-source": "^1.1.0"
}

Incompatibility with Node 11?

I don't like to ignore engine dependencies in my project, just wanted to know if this is intentional for a known reason or just being cautious?

"engines": {
    "node": "8.* || 10.* || >= 12.*"
  },

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.