All Projects → Pauan → rollup-plugin-purs

Pauan / rollup-plugin-purs

Licence: other
Bundles PureScript modules with Rollup

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to rollup-plugin-purs

rollup-plugin-closure-compiler-js
Rollup plugin for optimizing JavaScript with google-closure-compiler-js.
Stars: ✭ 31 (-56.34%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-html
Import HTML files as strings in rollup build
Stars: ✭ 36 (-49.3%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-userscript-metablock
Transform json file to userscript metablock and append on.
Stars: ✭ 26 (-63.38%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-tagged-template
Use plain HTML files as tagged templates.
Stars: ✭ 24 (-66.2%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-sizes
Rollup plugin to display bundle contents & size information
Stars: ✭ 77 (+8.45%)
Mutual labels:  rollup, rollup-plugin
postcss-font-grabber
A postcss plugin, it grabs remote font files and update your CSS, just like that.
Stars: ✭ 26 (-63.38%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-generate-package-json
Generate package.json file with packages from your bundle using Rollup
Stars: ✭ 29 (-59.15%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-generate-html-template
Rollup plugin for automatically injecting a script tag with the final bundle into an html file.
Stars: ✭ 58 (-18.31%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-external-globals
Transform external imports into global variables like output.globals.
Stars: ✭ 57 (-19.72%)
Mutual labels:  rollup, rollup-plugin
web-config
A Rollup configuration to build modern web applications with sweet features as for example SCSS imports, Service Worker generation with Workbox, Karma testing, live reloading, coping resources, chunking, treeshaking, Typescript, license extraction, filesize visualizer, JSON import, budgets, build progress, minifying and compression with brotli a…
Stars: ✭ 17 (-76.06%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-inject-process-env
Inject environment variables in process.env with Rollup
Stars: ✭ 48 (-32.39%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-markdown
import JavaScript from Markdown code blocks
Stars: ✭ 16 (-77.46%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-lit-css
Moved to https://github.com/bennypowers/lit-css
Stars: ✭ 35 (-50.7%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-collect-sass
Collect Sass, then compile
Stars: ✭ 17 (-76.06%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-jscc
Conditional compilation and compile-time variable replacement for Rollup
Stars: ✭ 52 (-26.76%)
Mutual labels:  rollup, rollup-plugin
npm-es-modules
Breakdown of 7 different ways to use ES modules with npm today.
Stars: ✭ 67 (-5.63%)
Mutual labels:  rollup
vue-methods-promise
Let Vue methods support return Promise
Stars: ✭ 35 (-50.7%)
Mutual labels:  rollup
vue-frag-plugin
Webpack/Rollup/Vite plugin to add multiple root-node support to Vue 2 SFCs
Stars: ✭ 37 (-47.89%)
Mutual labels:  rollup
rollup-plugin-istanbul
Seamless integration between Rollup and Istanbul
Stars: ✭ 39 (-45.07%)
Mutual labels:  rollup
ts-react-boilerplate
Chrome extension boilerplate with TypeScript and React
Stars: ✭ 53 (-25.35%)
Mutual labels:  rollup

rollup-plugin-purs

Bundles PureScript modules with Rollup

Why Rollup?

Here are the file sizes for the examples/tab-organizer program:

Bundler Unminified JSMin UglifyJS
rollup-plugin-purs 112.2 kB 70.3 kB 35.7 kB
purs bundle 157.8 kB 107.2 kB 65.2 kB
webpack 977.4 kB 654.0 kB 178.8 kB

Installation

  1. Add the following to your package.json:

    "devDependencies": {
      "rollup": "^0.41.6",
      "rollup-plugin-purs": "^1.0.35"
    },
    "scripts": {
      "build": "rollup --config"
    }
  2. Run npm install

  3. Place this code into a file called rollup.config.js:

    import purs from "rollup-plugin-purs";
    
    export default {
      entry: "src/Main.purs",
      dest: "bundle.js",
      format: "iife",
      sourceMap: true,
      plugins: [
        purs()
      ]
    };
  4. This plugin does not compile PureScript code, so you will need to run pulp build -- --source-maps (or equivalent)

  5. Run npm run build

  6. The final bundle is in the bundle.js file. Enjoy the smaller file size and optimizations!

You can see an example program in the examples/pulp init folder.

Options

These are the default options:

purs({
  include: undefined,      // Glob pattern for files/directories to include
  exclude: undefined,      // Glob pattern for files/directories to exclude
  buildDir: "output",      // Directory where the `purs compile` files are located
  runMain: true,           // Whether to call the `main` function or not
  debug: true,             // Displays additional warnings and statistics
  optimizations: {
    uncurry: true,         // Whether to apply the uncurrying optimization or not
    inline: true,          // Whether to inline some functions or not
    removeDeadCode: true,  // Whether to remove dead code or not
    assumePureVars: true   // Whether to assume that variable assignment is always pure
  }
})

The default options should be fine for most use cases.

Optimizations

These are the optimizations which can be turned on or off:

  • uncurry

    Replaces curried functions with uncurried functions, for improved performance and smaller file size.

  • inline

    Inlines some functions, which can increase performance and decrease the file size.

    It also inlines typeclass instance methods when it can. This can dramatically improve performance and reduce the file size.

  • removeDeadCode

    Removes code which is not used. This dramatically reduces the file size.

  • assumePureVars

    When there is a variable assignment like var foo = ... it will assume that the ... is pure. When used in combination with removeDeadCode, this significantly reduces the file size.

    If assumePureVars is false, then rollup-plugin-purs only removes unused variables if it can prove that the variables are pure. But sometimes it won't remove unused variables, because it's not smart enough to realize that the variables are pure.

    If assumePureVars is true, then rollup-plugin-purs will remove all unused variables, even if it can't prove that the variables are pure.

    PureScript variables are always pure, so assumePureVars is safe. But if you do weird things with the FFI, or if you use an unsafe PureScript function, or if you import a JavaScript library, then assumePureVars might break your program.

In addition to the above optimizations, there are some optimizations which are always applied:

  • Constant propagation / folding

Planned optimizations

  • Common subexpression elimination

Comment pragmas

You can disable certain warnings by including a special comment in your code:

// rollup-plugin-purs ignore dynamic exports
// rollup-plugin-purs ignore dynamic require
// rollup-plugin-purs ignore dynamic module

Each comment disables a specific warning.

The comments must be exactly the same as above, and they must be placed at the top-level of your code, with zero spaces to the left of the comment.

Converting from CommonJS to ES6 modules

This package also contains a convert-commonjs program which can be used to convert a file from CommonJS to ES6 modules.

You can run node_modules/.bin/convert-commonjs input.js > output.js which will take the input.js file (which is CommonJS) and will output to the output.js file (which is ES6 modules).

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].