All Projects → ethul → Purs Loader

ethul / Purs Loader

Licence: mit
PureScript loader for webpack

Programming Languages

javascript
184084 projects - #8 most used programming language
purescript
368 projects

Projects that are alternatives of or similar to Purs Loader

Node Hot Loader
Hot module replacement (hot reload) for Node.js applications. Develop without server restarting.
Stars: ✭ 111 (-39.01%)
Mutual labels:  webpack, loader
Omil
📝Webpack loader for Omi.js React.js and Rax.js components 基于 Omi.js,React.js 和 Rax.js 单文件组件的webpack模块加载器
Stars: ✭ 140 (-23.08%)
Mutual labels:  webpack, loader
Sass Vars Loader
Use Sass variables defined in Webpack config or in external Javascript or JSON files
Stars: ✭ 112 (-38.46%)
Mutual labels:  webpack, loader
Grow Loader
A webpack loader to split class methods by decorators
Stars: ✭ 89 (-51.1%)
Mutual labels:  webpack, loader
Img Loader
Image minimizing loader for webpack
Stars: ✭ 161 (-11.54%)
Mutual labels:  webpack, loader
Fe Blog
前端学习笔记,JavaScript基础,LeetCode,手写API,Vue源码解析,前端面试题
Stars: ✭ 99 (-45.6%)
Mutual labels:  webpack, loader
Aot Loader
⚠️ [Deprecated] Ahead-of-Time Compiler for Webpack.
Stars: ✭ 121 (-33.52%)
Mutual labels:  webpack, loader
Eslint Loader
[DEPRECATED] A ESlint loader for webpack
Stars: ✭ 1,067 (+486.26%)
Mutual labels:  webpack, loader
Webpack Fast Refresh
React Fast Refresh plugin and loader for webpack
Stars: ✭ 155 (-14.84%)
Mutual labels:  webpack, loader
Vue Webpack Config
Koa2、Webpack、Vue、React、Node
Stars: ✭ 151 (-17.03%)
Mutual labels:  webpack, loader
React Hot Loader Loader
A Webpack Loader that automatically inserts react-hot-loader to your App 👨‍🔬
Stars: ✭ 176 (-3.3%)
Mutual labels:  webpack, loader
Webpack Config Handbook
Minimum Webpack config handbook & examples
Stars: ✭ 165 (-9.34%)
Mutual labels:  webpack, loader
Mina Webpack
🍱 Mina single-file-component meets Webpack
Stars: ✭ 77 (-57.69%)
Mutual labels:  webpack, loader
Vue Svg Inline Loader
Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.
Stars: ✭ 105 (-42.31%)
Mutual labels:  webpack, loader
Extracted Loader
It reloads extracted stylesheets extracted with ExtractTextPlugin
Stars: ✭ 67 (-63.19%)
Mutual labels:  webpack, loader
Style Loader
Style Loader
Stars: ✭ 1,572 (+763.74%)
Mutual labels:  webpack, loader
Svgr
Transform SVGs into React components 🦁
Stars: ✭ 8,263 (+4440.11%)
Mutual labels:  webpack, loader
Node Native Ext Loader
Loader for Node native extensions
Stars: ✭ 51 (-71.98%)
Mutual labels:  webpack, loader
Workflow
一个工作流平台
Stars: ✭ 1,888 (+937.36%)
Mutual labels:  webpack, loader
Ts Tools
TypeScript Tools for Node.js
Stars: ✭ 162 (-10.99%)
Mutual labels:  webpack, loader

purs-loader

PureScript loader for webpack

  • Supports hot-reloading and rebuilding of single source files
  • Dead code elimination using the bundle option
  • Colorized build output using purescript-psa and the psc: "psa" option

Install

Install with npm.

// For PureScript 0.11 and newer
npm install purs-loader --save-dev

// For PureScript 0.9 and 0.10
npm install [email protected] --save-dev

// For PureScript 0.8
npm install [email protected] --save-dev

Example

const webpackConfig = {
  // ...
  loaders: [
    // ...
    {
      test: /\.purs$/,
      loader: 'purs-loader',
      exclude: /node_modules/,
      query: {
        spago: true,
        pscIde: true,
        src: ['src/**/*.purs']
      }
    }
    // ...
  ]
  // ...
}

Refer to the purescript-webpack-example for a more detailed example.

Options

Default options:

const loaderConfig = {
  psc: null, // purs compile
  pscArgs: {},
  pscBundle: null, // purs bundle
  pscBundleArgs: {},
  pscIde: false, // instant rebuilds using psc-ide-server (experimental)
  pscIdeClient: null, // purs ide client
  pscIdeClientArgs: {}, // for example, to use different port {port: 4088}
  pscIdeServer: null, // purs ide server
  pscIdeServerArgs: {}, // for example, to change the port {port: 4088}
  pscIdeRebuildArgs: {}, // for example, for sourcemaps {codegen: ['js', 'sourcemaps']}
  pscIdeColors: false, // defaults to true if psc === 'psa'
  pscPackage: false, // include dependencies from psc-package
  spago: false, // include dependencies from spago
  bundleOutput: 'output/bundle.js',
  bundleNamespace: 'PS',
  bundle: false,
  warnings: true,
  watch: false, // indicates if webpack is in watch mode
  output: 'output',
  src: [
    path.join('src', '**', '*.purs'),
    // if pscPackage = true
    // source paths reported by `psc-package sources`
    // if spago = true
    // source paths reported by `spago sources`
    // if pscPackage = false and spago = false
    path.join('bower_components', 'purescript-*', 'src', '**', '*.purs')
  ]
}

psc-ide support (experimental)

Experimental support for instant rebuilds using psc-ide-server can be enabled via the pscIde: true option. You can use an already running psc-ide-server instance by specifying the port in pscIdeArgs, if there is no server running this loader will start one for you.

psc-package support (experimental)

Set pscPackage query parameter to true to enable psc-package support. The psc-package-supplied source paths will be appended to src parameter.

spago support (experimental)

Set spago query parameter to true to enable spago support. The spago-supplied source paths will be appended to src parameter.

Troubleshooting

Slower webpack startup after enabling psc-ide support?

By default, the psc-ide-server will be passed the globs from query.src, this is helpful for other tools using psc-ide-server (for example IDE plugins), however it might result in a slower initial webpack startup time (rebuilds are not affected). To override the default behaviour, add: pscIdeServerArgs: { "_": ['your/*globs/here'] } to the loader config

Errors not being displayed in watch mode?

When the watch option is set to true, psc errors are appended to webpack's compilation instance errors array and not passed back as an error to the loader's callback. This may result in the error not being reported by webpack. To display errors, the following plugin may be added to the webpack config.

const webpackConfig = {
  // ...
  plugins: [
    function(){
      this.plugin('done', function(stats){
        process.stderr.write(stats.toString('errors-only'));
      });
    }
  ]
  // ...
}

Error spawn ENOENT

This is caused when the loader tries to spawn a binary that does not exists (file or directory not found). If you call webpack like webpack or webpack --watch, then ensure that all required binaries that the loader depends on are available in your $PATH.

If you run webpack through an npm script (e.g., npm run or npm start) on NixOS, then it will first attempt to find binaries in node_packages/.bin. If you have the compiler installed through npm and it finds it there, this will cause ENOENTon Nix, because the binary needs to be patched first, but npm will install the binary that is linked with /lib64/ld-linux-x86-64.so.2 - a file that will not exist at that path in NixOS. The solution is to simply use the compiler from haskellPackages.purescript and make sure that it's available in $PATH. For more information about how to make it work on Nix, see Purescript Webpack Example

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].