Skip to content

Commit

Permalink
Merge 9d11b8a into 26c6cd5
Browse files Browse the repository at this point in the history
  • Loading branch information
homer0 committed Feb 5, 2019
2 parents 26c6cd5 + 9d11b8a commit 673400e
Show file tree
Hide file tree
Showing 27 changed files with 3,161 additions and 2,154 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6
8
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- "6.14"
- "8.11"
after_success:
- 'cat ./coverage/lcov.info | ./node_modules/.bin/coveralls'
62 changes: 30 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,55 @@
"author": "Leonardo Apiwan (@homer0) <me@homer0.com>",
"license": "MIT",
"dependencies": {
"projext": "^5.0.0",
"wootils": "^1.3.2",
"projext": "homer0/projext#next",
"wootils": "^1.4.0",
"jimple": "1.5.0",
"fs-extra": "7.0.0",
"fs-extra": "7.0.1",
"extend": "3.0.2",

"rollup": "0.64.1",
"rollup-plugin-commonjs": "9.1.5",
"rollup-plugin-node-resolve": "3.3.0",
"rollup-plugin-uglify": "4.0.0",
"rollup": "1.1.2",
"rollup-plugin-commonjs": "9.2.0",
"rollup-plugin-node-resolve": "4.0.0",
"rollup-plugin-uglify": "6.0.2",
"rollup-plugin-html": "0.2.1",
"rollup-plugin-babel": "3.0.7",
"rollup-plugin-json": "3.0.0",
"rollup-plugin-replace": "2.0.0",
"rollup-plugin-sass": "0.9.2",
"rollup-pluginutils": "2.3.1",
"rollup-plugin-babel": "4.3.2",
"rollup-plugin-json": "3.1.0",
"rollup-plugin-replace": "2.1.0",
"rollup-plugin-sass": "1.1.0",
"rollup-pluginutils": "2.3.3",

"builtin-modules": "3.0.0",

"postcss": "7.0.2",
"postcss-modules": "1.3.2",
"postcss": "7.0.14",
"postcss-modules": "1.4.1",

"node-sass": "4.9.3",
"mime": "2.3.1",
"opener": "1.5.0",
"node-zopfli": "2.0.2",
"prettysize": "1.1.0",
"colors": "1.3.1",
"node-sass": "4.11.0",
"mime": "2.4.0",
"opener": "1.5.1",
"prettysize": "2.0.0",
"colors": "1.3.3",

"babel-core": "6.26.3",
"babel-preset-env": "1.7.0",
"babel-plugin-external-helpers": "6.22.0"
"@babel/core": "7.2.2",
"@babel/preset-env": "7.3.1"
},
"devDependencies": {
"eslint": "5.3.0",
"eslint": "5.13.0",
"eslint-config-airbnb-base": "13.1.0",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-node": "7.0.1",
"jest-ex": "5.0.0",
"jest-cli": "23.5.0",
"jasmine-expect": "3.8.3",
"eslint-plugin-import": "2.16.0",
"eslint-plugin-node": "8.0.1",
"jest-ex": "^6.0.0",
"jest-cli": "24.0.0",
"jasmine-expect": "4.0.1",
"jimpex": "^2.1.1",
"esdoc": "1.1.0",
"esdoc-standard-plugin": "1.0.0",
"esdoc-node": "1.0.3",
"leasot": "6.3.0",
"esdoc-node": "1.0.4",
"leasot": "7.2.0",
"coveralls": "3.0.2"
},
"engine-strict": true,
"engines": {
"node": ">=6.0.0",
"node": ">=8.0.0",
"npm": ">=3.0.0"
},
"main": "src/index.js",
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/compression/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require('path');
const zlib = require('zlib');
const rollupUtils = require('rollup-pluginutils');
const extend = require('extend');
const fs = require('fs-extra');
const zopfli = require('node-zopfli');
const { deferred } = require('wootils/shared');
/**
* This is a Rollup plugin that takes all the files that match an specific filter and compress using
Expand Down Expand Up @@ -48,7 +48,7 @@ class ProjextRollupCompressionPlugin {
/**
* @ignore
*/
this.onwrite = this.onwrite.bind(this);
this.writeBundle = this.writeBundle.bind(this);
}
/**
* Gets the plugin options
Expand All @@ -63,7 +63,7 @@ class ProjextRollupCompressionPlugin {
* @return {Promise<Array,Error>} If everything goes well, the Promise will resolve on a list
* of {@link ProjextRollupCompressionPluginEntry} objects.
*/
onwrite() {
writeBundle() {
return Promise.all(this._findAllTheFiles().map((file) => this._compressFile(file)));
}
/**
Expand Down Expand Up @@ -131,7 +131,7 @@ class ProjextRollupCompressionPlugin {
fs.createReadStream(filepath)
.on('error', reject)
// Compress the file.
.pipe(zopfli.createGzip())
.pipe(zlib.createGzip())
// Write the compressed file.
.pipe(fs.createWriteStream(newFilepath))
.on('error', (error) => {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/copy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ProjextRollupCopyPlugin {
/**
* @ignore
*/
this.onwrite = this.onwrite.bind(this);
this.writeBundle = this.writeBundle.bind(this);
}
/**
* Gets the plugin options
Expand All @@ -59,7 +59,7 @@ class ProjextRollupCopyPlugin {
* the plugin will filter the files that doesn't exist and copy the rest.
* @return {Promise<Array,Error>} The resolved array has the path for each copied file.
*/
onwrite() {
writeBundle() {
// Reset the _"cache"_.
this._createdDirectoriesCache = [];
return Promise.all(
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ProjextRollupCSSPlugin {
/**
* @ignore
*/
this.ongenerate = this.ongenerate.bind(this);
this.writeBundle = this.writeBundle.bind(this);
}
/**
* Gets the plugin options
Expand Down Expand Up @@ -168,7 +168,7 @@ class ProjextRollupCSSPlugin {
} else {
/**
* Finally, if the code will be added to a bundle, keep the code and path
* information so they'll be used on `ongenerate` and set the default export as
* information so they'll be used on `writeBundle` and set the default export as
* an empty string.
*/
this._toBundle.push({
Expand Down Expand Up @@ -200,7 +200,7 @@ class ProjextRollupCSSPlugin {
* This gets called by Rollup when the bundle is being generated. It takes care, if needed, to
* create the stylesheet bundle.
*/
ongenerate() {
writeBundle() {
const { insert, output } = this._options;
/**
* If the code shouldn't be injected, there's a valid path for the bundle and there are files
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/devServer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ProjextRollupDevServerPlugin {
/**
* @ignore
*/
this.onwrite = this.onwrite.bind(this);
this.writeBundle = this.writeBundle.bind(this);
/**
* @ignore
*/
Expand All @@ -136,7 +136,7 @@ class ProjextRollupDevServerPlugin {
*/
showURL() {
return {
onwrite: () => {
writeBundle: () => {
// A small _"timeout-hack"_ to show the message after Rollup's output
setTimeout(() => this._logger.success(`Your app is running on ${this.url}`), 0);
},
Expand All @@ -146,7 +146,7 @@ class ProjextRollupDevServerPlugin {
* This is called after Rollup finishes writing the files on the file system. It checks if
* there's an instance of the server running and if there isn't, it creates a new one.
*/
onwrite() {
writeBundle() {
// Validate that there's no instance already running.
if (!this._instance) {
// Get the server basic options.
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/nodeRunner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ProjextRollupNodeRunnerPlugin {
/**
* @ignore
*/
this.onwrite = this.onwrite.bind(this);
this.writeBundle = this.writeBundle.bind(this);
/**
* @ignore
*/
Expand All @@ -93,7 +93,7 @@ class ProjextRollupNodeRunnerPlugin {
* This is called after Rollup finishes writing the files on the file system. It takes care of
* stopping the bundle execution, if it's already running, and starting it again.
*/
onwrite() {
writeBundle() {
this._stopExecution();
this._startExecution();
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/stats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ProjextRollupStatsPlugin {
}
// Return the _"sub plugin"_.
return {
onwrite: () => {
writeBundle: () => {
/**
* Add any extra entry specified on the options. The reason they're being added here
* instead of the parent scope it's because the `reset` _"sub plugin"_ may remove them
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/stylesheetAssets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class ProjextRollupStylesheetAssetsPlugin {
/**
* @ignore
*/
this.onwrite = this.onwrite.bind(this);
this.writeBundle = this.writeBundle.bind(this);
}
/**
* Gets the plugin options
Expand All @@ -127,7 +127,7 @@ class ProjextRollupStylesheetAssetsPlugin {
* This is called after Rollup finishes writing the files on the file system. This is where
* the plugin opens the file and process the stylesheet/CSS blocks.
*/
onwrite() {
writeBundle() {
const { stylesheet } = this._options;
// Validate that the target file exists.
if (fs.pathExistsSync(stylesheet)) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class ProjextRollupTemplatePlugin {
/**
* @ignore
*/
this.onwrite = this.onwrite.bind(this);
this.writeBundle = this.writeBundle.bind(this);
}
/**
* Gets the plugin options
Expand All @@ -107,7 +107,7 @@ class ProjextRollupTemplatePlugin {
* This is called by Rollup after writing the files on the file system. This is where the plugin
* parses the template and generates the HTML file.
*/
onwrite() {
writeBundle() {
// Reset the directories cache.
this._createdDirectoriesCache = [];
// Define the async attribute.
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/urls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ProjextRollupURLsPlugin {
/**
* @ignore
*/
this.onwrite = this.onwrite.bind(this);
this.writeBundle = this.writeBundle.bind(this);
}
/**
* Gets the plugin options
Expand Down Expand Up @@ -108,7 +108,7 @@ class ProjextRollupURLsPlugin {
* This is called by Rollup after it finishes writing the files on the file system. The method
* will loop the queue and copy all the files that matched a filter during the `load` process.
*/
onwrite() {
writeBundle() {
// Loop all the files.
this._toCopy.forEach((toCopy) => {
// Make sure the output directory exists.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RollupBrowserDevelopmentConfiguration extends ConfigurationFile {
let devServerInstance;
if (target.runOnDevelopment) {
devServerInstance = devServer(pluginSettings.devServer);
statsLogSettings.afterLog = devServerInstance.showURL().onwrite;
statsLogSettings.afterLog = devServerInstance.showURL().writeBundle;
}

// Define the plugins list.
Expand Down
26 changes: 17 additions & 9 deletions src/services/configurations/pluginsConfiguration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs-extra');
const postcss = require('postcss');
const LazyResult = require('postcss/lib/lazy-result');
const postcssModules = require('postcss-modules');
const builtinModules = require('builtin-modules');
const nodeSass = require('node-sass');
Expand All @@ -15,9 +16,7 @@ class RollupPluginSettingsConfiguration extends ConfigurationFile {
* @param {Logger} appLogger To send to the plugins that support a logger.
* @param {BabelConfiguration} babelConfiguration To get the target Babel configuration.
* @param {BabelHelper} babelHelper To disable the `modules` setting of the Babel
* env preset for a target, as Rollup requires,
* and include the `external-helpers` plugin, to
* optimize the transpilation.
* env preset for a target, as Rollup requires.
* @param {Events} events To reduce the settings.
* @param {Object} packageInfo To get the dependencies and define them as
* externals for Node targets.
Expand Down Expand Up @@ -313,9 +312,7 @@ class RollupPluginSettingsConfiguration extends ConfigurationFile {
// Get the target Babel configuration.
const baseConfiguration = this.babelConfiguration.getConfigForTarget(target);
// Disable the `modules` feature for the `env` preset.
let configuration = this.babelHelper.disableEnvPresetModules(baseConfiguration);
// Add the `external-helpers` plugin to optimize the transpilation.
configuration = this.babelHelper.addPlugin(configuration, 'external-helpers');
const configuration = this.babelHelper.disableEnvPresetModules(baseConfiguration);
// Define the plugin settings.
const settings = Object.assign(
{},
Expand Down Expand Up @@ -1245,9 +1242,20 @@ class RollupPluginSettingsConfiguration extends ConfigurationFile {
let processor;
// Avoid using `postcss` if not needed
if (plugins.length || options.map || options.from) {
processor = postcss(plugins)
// Process the stylesheet code.
.process(css, options);
// If we actually have plugins...
if (plugins.length) {
// Let's use `postcss` like you would normally do.
processor = postcss(plugins)
// Process the stylesheet code.
.process(css, options);
} else {
/**
* But if we are using `postcss` just to get the source map, let's wrap it on a
* `LazyResult`. It seems to be the only way to hide the warning that we are not
* using plugins.
*/
processor = new LazyResult(postcss(), css, options);
}
} else {
processor = Promise.resolve({
css: css.replace(map, '').trim(),
Expand Down
6 changes: 3 additions & 3 deletions src/typedef.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@

/**
* @typedef {Object} ProjextRollupStatsPluginLog
* @property {function} onwrite The method Rollup calls after writing the files on the file system.
* When this happens, the plugin will log the report table on the
* console.
* @property {function} writeBundle The method Rollup calls after writing the files on the file
* system. When this happens, the plugin will log the report
* table on the console.
*/

/**
Expand Down
Loading

0 comments on commit 673400e

Please sign in to comment.