- const options = Object.assign({
- context: config.context,
- psc: 'psc',
- pscArgs: {},
- pscBundle: 'psc-bundle',
- pscBundleArgs: {},
- pscIde: false,
- pscIdeColors: webpackOptions.psc === 'psa' || query.psc === 'psa',
- pscIdeArgs: {},
- bundleOutput: 'output/bundle.js',
- bundleNamespace: 'PS',
- bundle: false,
- warnings: true,
- output: 'output',
- src: [
- path.join('src', '**', '*.purs'),
- path.join('bower_components', 'purescript-*', 'src', '**', '*.purs')
- ],
- ffi: [
- path.join('src', '**', '*.js'),
- path.join('bower_components', 'purescript-*', 'src', '**', '*.js')
- ],
- }, webpackOptions, query)
-
- this.cacheable && this.cacheable()
-
- let cache = config.purescriptLoaderCache = config.purescriptLoaderCache || {
- rebuild: false,
- deferred: [],
- bundleModules: [],
- }
-
- if (!config.purescriptLoaderInstalled) {
- config.purescriptLoaderInstalled = true
-
- // invalidate loader cache when bundle is marked as invalid (in watch mode)
- this._compiler.plugin('invalid', () => {
- cache = config.purescriptLoaderCache = {
- rebuild: options.pscIde,
- deferred: [],
- ideServer: cache.ideServer
- }
- })
-
- // add psc warnings to webpack compilation warnings
- this._compiler.plugin('after-compile', (compilation, callback) => {
- if (options.warnings && cache.warnings && cache.warnings.length) {
- compilation.warnings.unshift(`PureScript compilation:\n${cache.warnings.join('')}`)
- }