From 08969d1245dd2a0b58262a008b64dbe13878e88a Mon Sep 17 00:00:00 2001 From: Eugene Kuzmenko Date: Fri, 22 Jan 2016 20:22:06 +0200 Subject: [PATCH] [removed] support for CSS Modules. Though, certainly a good idea, the implementation is based solely on hacks, which I just do not feel comfortable having on the project. Also, switched to using the Babel OptionManager, instead of loading the configuration file manually. --- .babelrc | 21 ++++++++++++- config/babel.json | 30 ------------------- config/webpack.node.js | 21 ------------- docs/JSCompiler.html | 36 +++------------------- docs/JSCompiler.js.html | 42 ++------------------------ docs/quicksearch.html | 2 +- interfaces/babel-core.js | 3 ++ lib/Compiler.js | 10 +++---- lib/DevServer.js | 10 +++---- lib/Documentation.js | 10 +++---- lib/JS.js | 10 +++---- lib/JSCompiler.js | 65 ++++------------------------------------ lib/JSLint.js | 10 +++---- lib/NativeProcess.js | 10 +++---- lib/SASS.js | 10 +++---- lib/SASSCompiler.js | 10 +++---- lib/SASSLint.js | 10 +++---- package.json | 1 - src/JSCompiler.js | 42 ++------------------------ test/JSCompiler.spec.js | 48 +++++++++++++---------------- 20 files changed, 105 insertions(+), 296 deletions(-) delete mode 100644 config/babel.json delete mode 100644 config/webpack.node.js diff --git a/.babelrc b/.babelrc index 98e79fc..426b435 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,22 @@ { - "extends": "./config/babel.json" + "presets": [ "es2015", "stage-2", "react" ], + "plugins": [ + "transform-class-properties", + "transform-react-display-name", + "transform-runtime" + ], + "env": { + "production": { + "plugins": [ + "transform-member-expression-literals", + "transform-property-literals", + "transform-merge-sibling-variables", + "transform-remove-debugger", + "transform-react-constant-elements", + "transform-react-inline-elements", + "transform-inline-environment-variables", + "transform-node-env-inline" + ] + } + } } diff --git a/config/babel.json b/config/babel.json deleted file mode 100644 index 6ed034f..0000000 --- a/config/babel.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "env": { - "development": { - "presets": [ "es2015", "stage-2", "react" ], - "plugins": [ - "transform-class-properties", - "transform-react-display-name", - "transform-runtime", - ["webpack-loaders", {"config": "./config/webpack.node.js", "verbose": false}] - ] - }, - "production": { - "presets": [ "es2015", "stage-2", "react" ], - "plugins": [ - "transform-class-properties", - "transform-react-display-name", - "transform-runtime", - ["webpack-loaders", {"config": "./config/webpack.node.js", "verbose": false}], - "transform-member-expression-literals", - "transform-property-literals", - "transform-merge-sibling-variables", - "transform-remove-debugger", - "transform-react-constant-elements", - "transform-react-inline-elements", - "transform-inline-environment-variables", - "transform-node-env-inline" - ] - } - } -} diff --git a/config/webpack.node.js b/config/webpack.node.js deleted file mode 100644 index c69b819..0000000 --- a/config/webpack.node.js +++ /dev/null @@ -1,21 +0,0 @@ -var autoprefixer = require('autoprefixer'); -var importer = require('node-sass-import-once'); - -module.exports = { - output: {libraryTarget: 'commonjs2'}, - module: { - loaders: [{ - test: /\.scss$/, - loaders: ['style?singleton', 'css?modules&minimize&importLoaders=1&sourceMap', 'postcss', 'sass?sourceMap'] - }] - }, - postcss: function () { - return [autoprefixer]; - }, - sassLoader: { - importer: importer, - importOnce: {index: true, css: false, bower: false}, - includePaths: ['node_modules/bootstrap-sass/assets/stylesheets', 'node_modules'], - precision: 8 - } -}; diff --git a/docs/JSCompiler.html b/docs/JSCompiler.html index fbb0226..74f1628 100644 --- a/docs/JSCompiler.html +++ b/docs/JSCompiler.html @@ -253,7 +253,7 @@
Parameters:
@@ -615,7 +615,7 @@
Parameters:
@@ -860,7 +860,6 @@

fe(inPath, outPath,

Compiles, bundles (in production mode also minifies and g-zips) a JavaScript file for the front end.

-

Supports importing (requiring) .scss files inside of JavaScript.

@@ -1049,7 +1048,7 @@

Parameters:
@@ -1058,13 +1057,6 @@
Parameters:
-
See:
-
- -
- @@ -1081,26 +1073,6 @@
Parameters:
-
Returns:
- - - - -
-
- Type -
-
- -void - - - -
-
- - -
Example
@@ -1450,7 +1422,7 @@
Parameters:
diff --git a/docs/JSCompiler.js.html b/docs/JSCompiler.js.html index e923341..7059658 100644 --- a/docs/JSCompiler.js.html +++ b/docs/JSCompiler.js.html @@ -76,24 +76,20 @@

Source: JSCompiler.js

/* @flow */
 
-/* @flowignore */
-import config from '../config/babel';
 import {Compiler} from './Compiler';
 import type {ProgramData} from './Compiler';
 import {join, extname, dirname, basename} from 'path';
 import {readdir, stat, createReadStream, createWriteStream} from 'fs';
-import {transformFile} from 'babel-core';
+import {transformFile, OptionManager} from 'babel-core';
 import webpack from 'webpack';
 import MemoryFS from 'memory-fs';
 import UglifyJS from 'uglify-js';
-import autoprefixer from 'autoprefixer';
-import importer from 'node-sass-import-once';
 
 /* eslint-disable no-sync */
 
 /* @flowignore */
 const emptyFn: () => void = Function.prototype,
-    precision = 8,
+    manager = new OptionManager(),
     cache = {},
     fakeFS = new MemoryFS();
 
@@ -132,7 +128,7 @@ 

Source: JSCompiler.js

constructor(compress: boolean = true, options: Object = {}) { super(compress); - this.options = Object.assign({}, config.env[this.isProduction ? 'production' : 'development'], options); + this.options = manager.init({filename: __dirname, ...options}); this.processing = 0; } @@ -282,31 +278,16 @@

Source: JSCompiler.js

/** * Compiles, bundles (in production mode also minifies and g-zips) a JavaScript file for the front end. * - * Supports importing (requiring) `.scss` files inside of JavaScript. - * * @memberOf JSCompiler * @instance * @method fe * @param {string} inPath - the input path * @param {string} outPath - the output path * @param {Function} [callback=function () {}] - a callback function - * @return {void} - * @see {@link https://github.com/css-modules/css-modules|CSS Modules} * @example * compiler.fe('/path/to/an/input/file.js', '/path/to/the/output/file.js', callback); */ fe(inPath: string, outPath: string, callback: () => void = emptyFn) { - const {plugins} = this.options, - {NODE_ENV} = process.env; - - if (plugins) { - this.options.plugins = plugins.filter(plugin => 'webpack-loaders' !== plugin && 'webpack-loaders' !== plugin[0]); - } - - if (!this.isProduction) { - process.env.NODE_ENV = 'development'; - } - const compiler = webpack({ cache, debug: true, @@ -322,27 +303,10 @@

Source: JSCompiler.js

}, { test: /\.json$/, loader: 'json' - }, { - test: /\.scss$/, - loaders: ['style?singleton', 'css?modules&minimize&importLoaders=1&sourceMap', 'postcss', 'sass?sourceMap'] }] - }, - postcss: () => [autoprefixer], - sassLoader: { - importer, - importOnce: {index: true, css: false, bower: false}, - includePaths: ['node_modules/bootstrap-sass/assets/stylesheets', 'node_modules'], - precision } }); - /* istanbul ignore next */ - if (NODE_ENV) { - process.env.NODE_ENV = NODE_ENV; - } else { - delete process.env.NODE_ENV; - } - if (this.isProduction) { compiler.outputFileSystem = fakeFS; } diff --git a/docs/quicksearch.html b/docs/quicksearch.html index 4095d02..29b7a1a 100644 --- a/docs/quicksearch.html +++ b/docs/quicksearch.html @@ -7,7 +7,7 @@