Git Product home page Git Product logo

cara's Introduction

cara v0.1.0 experimental

const {Bundler} = require('cara')

const bundler = new Bundler()
const project = bundler.project({
  root: '/path/to/cwd',
  types: ['js'],
})

const bundle = project.bundle({
  dev: true,
  platform: 'ios',
})

project.crawl({
  exclude: ['*.test.js'],
})

const code = await bundle.read()

Ready to dive deeper? Read this in-depth guide or view the API documentation.

cara's People

Contributors

aleclarson avatar

Watchers

 avatar  avatar

cara's Issues

Take @import location into account

Currently, the CSS bundler always hoists @import statements to the top of the file. Instead, if CSS exists both above and below an @import statement, the bundler should split the parent module into two parts and insert the dependency between them. Similarly, if an @import statement is at the bottom of a file, avoid hoisting the dependency but don't split the parent unless necessary.

JS require/import globbing

Imagine a file tree like the following:

  • models/
    • user.js
    • page.js
    • item.js
// Using import syntax
import {user, page, item} from './models/*'

// Using require syntax
const models = require('./models/*')

Package aliasing

There are situations where two packages have the same API, but the implementations are for separate platforms. If you control each package, you could theoretically combine them and use .web.js and .ios.js for every file in the package (and possibly share some modules with common functions). But it may be easier to keep the implementations split between two packages and simply have the bundler determine which package should be used depending on platform (or maybe some other heuristic).

Unsure on what the API would look like for redirection. I'll update this issue at a later date.

Importing package main without filename

Assuming a package's entry module is index.js in the root directory, using require('.') from a sibling module or require('..') from a module in a sub-directory is not correctly resolved.

JS tree shaking

Using ES modules, we can eliminate unused modules by statically analyzing the AST. There's probably an NPM package that does this.

We may also want to use babel-plugin-minify-dead-code-elimination to eliminate dead code within each module.

These things would only be done for production bundles, since parsing the AST on every change is slow unless we keep ASTs in memory like Parcel does (which may be something we do down the line).

Application source root

The entry package (also known as "the application") should be able to specify a sourceRoot that allows require calls to avoid relative paths (eg: ../../utils/foo) in favor of paths like utils/foo.

On-demand plugin install

Include plugin detection within src/plugins/*.js files, paired with which NPM package should be installed (global cache?) when a bundle needs the plugin.

Right now, the Babel, TypeScript, and SASS plugins are installed automatically, which is not ideal.

@import globbing

Support globbing (like @import 'mixins/*') in any language that compiles down to CSS.

Here's a repository that adds this functionality to SASS in particular.

Crashes on merge conflict inside package.json

Using git while the bundler is active is not without its issues.

When a merge conflict occurs within the package.json file of a dependency, the bundler will crash because of the syntax error caused by <<<.

Support CSS plugins for all packages

Currently, only the entry package can use CSS plugins like Sass or PostCSS. We'll need to apply plugins from the bottom-up, where packages without dependencies are processed first. We may need a solution for packages that provide Sass variables to their parent packages (is that a popular thing to do?).

Add a plugin for sub-bundles

Bundle-ception, a bundle within a bundle, but no module system. When a package uses the "sub-bundle" plugin, all of its modules are combined into a single module. Each module will always appear above its parent modules. The modules which are only imported by an outside module will appear in the order they were imported. Duplicate require calls and import statements would need to be stripped, so the package can still be developed as if it's not being combined into a single module.

Reload package plugins when configuration changes

As a luxury feature, this would be awesome. For example, if the "postcss" property in package.json is changed, reload the postcss plugin for that package. Another example is reloading the babel plugin when a package's .babelrc changes.

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.