Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
[removed] support for CSS Modules. Though, certainly a good idea, the…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
thealjey committed Jan 22, 2016
1 parent 4085a22 commit 08969d1
Show file tree
Hide file tree
Showing 20 changed files with 105 additions and 296 deletions.
21 changes: 20 additions & 1 deletion .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"
]
}
}
}
30 changes: 0 additions & 30 deletions config/babel.json

This file was deleted.

21 changes: 0 additions & 21 deletions config/webpack.node.js

This file was deleted.

36 changes: 4 additions & 32 deletions docs/JSCompiler.html
Expand Up @@ -253,7 +253,7 @@ <h5>Parameters:</h5>
<ul class="dummy">
<li>
<a href="JSCompiler.js.html">JSCompiler.js</a>,
<a href="JSCompiler.js.html#sunlight-1-line-24">line 24</a>
<a href="JSCompiler.js.html#sunlight-1-line-20">line 20</a>
</li>
</ul>
</dd>
Expand Down Expand Up @@ -615,7 +615,7 @@ <h5>Parameters:</h5>
<ul class="dummy">
<li>
<a href="JSCompiler.js.html">JSCompiler.js</a>,
<a href="JSCompiler.js.html#sunlight-1-line-182">line 182</a>
<a href="JSCompiler.js.html#sunlight-1-line-178">line 178</a>
</li>
</ul>
</dd>
Expand Down Expand Up @@ -860,7 +860,6 @@ <h4 class="name" id="fe"><span class="type-signature"></span>fe(inPath, outPath,

<div class="description">
<p>Compiles, bundles (in production mode also minifies and g-zips) a JavaScript file for the front end.</p>
<p>Supports importing (requiring) <code>.scss</code> files inside of JavaScript.</p>
</div>


Expand Down Expand Up @@ -1049,7 +1048,7 @@ <h5>Parameters:</h5>
<ul class="dummy">
<li>
<a href="JSCompiler.js.html">JSCompiler.js</a>,
<a href="JSCompiler.js.html#sunlight-1-line-206">line 206</a>
<a href="JSCompiler.js.html#sunlight-1-line-202">line 202</a>
</li>
</ul>
</dd>
Expand All @@ -1058,13 +1057,6 @@ <h5>Parameters:</h5>



<dt class="tag-see method-doc-label method-doc-details-label">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="https://github.com/css-modules/css-modules">CSS Modules</a></li>
</ul>
</dd>



</dl>
Expand All @@ -1081,26 +1073,6 @@ <h5>Parameters:</h5>



<h5>Returns:</h5>




<dl>
<dt>
Type
</dt>
<dd>

<span class="param-type">void</span>



</dd>
</dl>





<h5>Example</h5>
Expand Down Expand Up @@ -1450,7 +1422,7 @@ <h5>Parameters:</h5>
<ul class="dummy">
<li>
<a href="JSCompiler.js.html">JSCompiler.js</a>,
<a href="JSCompiler.js.html#sunlight-1-line-160">line 160</a>
<a href="JSCompiler.js.html#sunlight-1-line-156">line 156</a>
</li>
</ul>
</dd>
Expand Down
42 changes: 3 additions & 39 deletions docs/JSCompiler.js.html
Expand Up @@ -76,24 +76,20 @@ <h1 class="page-title">Source: JSCompiler.js</h1>
<pre
class="sunlight-highlight-javascript linenums">/* @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();

Expand Down Expand Up @@ -132,7 +128,7 @@ <h1 class="page-title">Source: JSCompiler.js</h1>

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;
}

Expand Down Expand Up @@ -282,31 +278,16 @@ <h1 class="page-title">Source: JSCompiler.js</h1>
/**
* 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 &amp;&amp; 'webpack-loaders' !== plugin[0]);
}

if (!this.isProduction) {
process.env.NODE_ENV = 'development';
}

const compiler = webpack({
cache,
debug: true,
Expand All @@ -322,27 +303,10 @@ <h1 class="page-title">Source: JSCompiler.js</h1>
}, {
test: /\.json$/,
loader: 'json'
}, {
test: /\.scss$/,
loaders: ['style?singleton', 'css?modules&amp;minimize&amp;importLoaders=1&amp;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;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/quicksearch.html

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions interfaces/babel-core.js
@@ -1,4 +1,7 @@
declare module 'babel-core' {
declare function transformFile(file: string, options: Object,
callback: (error: ?string, result: {code: string, map: string}) => void): void;
declare class OptionManager {
init(options: Object): Object;
}
}
10 changes: 5 additions & 5 deletions lib/Compiler.js
@@ -1,10 +1,5 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Compiler = undefined;

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
Expand All @@ -13,6 +8,11 @@ var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Compiler = undefined;

var _mkdirp = require('mkdirp');

var _mkdirp2 = _interopRequireDefault(_mkdirp);
Expand Down
10 changes: 5 additions & 5 deletions lib/DevServer.js
@@ -1,10 +1,5 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DevServer = undefined;

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
Expand All @@ -13,6 +8,11 @@ var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DevServer = undefined;

var _SASSCompiler = require('./SASSCompiler');

var _watch = require('./watch');
Expand Down
10 changes: 5 additions & 5 deletions lib/Documentation.js
@@ -1,10 +1,5 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Documentation = undefined;

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
Expand All @@ -13,6 +8,11 @@ var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Documentation = undefined;

var _NativeProcess = require('./NativeProcess');

var _fs = require('fs');
Expand Down
10 changes: 5 additions & 5 deletions lib/JS.js
@@ -1,10 +1,5 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.JS = undefined;

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
Expand All @@ -13,6 +8,11 @@ var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.JS = undefined;

var _JSCompiler = require('./JSCompiler');

var _NativeProcess = require('./NativeProcess');
Expand Down

0 comments on commit 08969d1

Please sign in to comment.