├── .editorconfig ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── __tests__ ├── css-entry-array.test.js ├── fixtures │ ├── css-array-entry │ │ ├── dir │ │ │ ├── l.css │ │ │ └── l.css.map │ │ ├── one.css │ │ ├── one.less │ │ ├── three.sass │ │ ├── two.css │ │ ├── two.less │ │ ├── two.scss │ │ ├── webpack.config.js │ │ ├── webpack.config.less.js │ │ └── webpack.config.sass.js │ ├── js-file-entry │ │ ├── one.css │ │ ├── one.less │ │ ├── styles-less.js │ │ ├── styles-sass.js │ │ ├── styles.js │ │ ├── three.sass │ │ ├── two.css │ │ ├── two.less │ │ ├── two.scss │ │ ├── webpack.config.js │ │ ├── webpack.config.less.js │ │ └── webpack.config.sass.js │ ├── options │ │ ├── preview │ │ │ ├── dir │ │ │ │ ├── b.css │ │ │ │ ├── b.css.map │ │ │ │ ├── b.js │ │ │ │ └── b.js.map │ │ │ └── webpack.config.js │ │ ├── shared │ │ │ ├── one.css │ │ │ ├── styles.js │ │ │ ├── three.css │ │ │ └── two.css │ │ └── verbose │ │ │ ├── dir │ │ │ ├── b.css │ │ │ └── b.css.map │ │ │ └── webpack.config.js │ └── should-not-omit │ │ ├── external-dep │ │ ├── dir │ │ │ ├── e.js │ │ │ └── e.js.map │ │ ├── webpack.config.arr.js │ │ └── webpack.config.js │ │ ├── external-internal │ │ ├── dir │ │ │ ├── j.css │ │ │ ├── j.css.map │ │ │ ├── j.js │ │ │ └── j.js.map │ │ ├── extin-entry.js │ │ ├── webpack.config.arr.js │ │ └── webpack.config.js │ │ ├── internal-dep │ │ ├── dir │ │ │ ├── b.js │ │ │ └── b.js.map │ │ └── webpack.config.js │ │ ├── mixed-dep │ │ ├── dir │ │ │ ├── d.css │ │ │ ├── d.css.map │ │ │ ├── d.js │ │ │ └── d.js.map │ │ └── webpack.config.js │ │ └── shared │ │ ├── colorful.js │ │ ├── common.js │ │ ├── mixed.js │ │ ├── one.css │ │ ├── one.js │ │ ├── styles.js │ │ ├── three.css │ │ └── two.css ├── js-file-entry.test.js ├── options.test.js ├── should-not-omit.test.js └── utils │ ├── chunk-should-contain-file.js │ ├── chunk-should-not-contain-file.js │ ├── file-should-exist.js │ └── file-should-not-exist.js ├── package.json ├── src └── index.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 4 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage/ 3 | test/fixtures/**/dir 4 | .nyc_output/ 5 | .coveralls.yml 6 | *.log 7 | /dist 8 | .vscode/ 9 | .yarn-error.log -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 10 4 | cache: 5 | yarn : true 6 | directories: 7 | - node_modules 8 | branches: 9 | only: 10 | - master 11 | - dev-branch 12 | notifications: 13 | email: false 14 | before_script: 15 | - npm prune 16 | script: 17 | - npm run test:cover 18 | after_success: 19 | - npm run report-coverage -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2017 Jessica Silva 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![npm version](https://img.shields.io/npm/v/webpack-omit-js-for-css-plugin.svg)](https://www.npmjs.com/package/webpack-omit-js-for-css-plugin) [![Build Status](https://travis-ci.org/jsilvax/webpack-omit-js-for-css-plugin.svg?branch=master)](https://travis-ci.org/jsilvax/webpack-omit-js-for-css-plugin) [![Coverage Status](https://coveralls.io/repos/github/jsilvax/webpack-omit-js-for-css-plugin/badge.svg)](https://coveralls.io/github/jsilvax/webpack-omit-js-for-css-plugin) 2 | 3 | # Webpack Omit JS for CSS Plugin 4 | 5 | This plugin will omit bundled JS files for dependencies that are exclusively CSS, which become obsolete once mini-css-extract-plugin extracts inlined CSS into its own .css file 6 | 7 | ## Rationale 8 | 9 | This plugin should ONLY be used for LEGACY applications, whose goal is to transition into using a modern build process. This is not an optimized solution. This should ONLY be used as a means to get a legacy application into using bundled entries. The configuration here will NOT provide an optimzed solution for an evergreen project. DO NOT USE THIS if you're working on a NEW PROJECT in 2020+. 10 | 11 | In certain cases, you may want to organize some of your CSS dependencies into single files or entry arrays within Webpack. Even though mini-css-extract-plugin extracts CSS into its own .css file, Webpack will still generate a js file that will never be needed. This plugin will omit these types of files before Webpack begins its emitting step, so that you don't have to manually remove them. This plugin is especially useful for Webpack bundles that use a hash in the filename, as these change on every compilation. 12 | 13 | Example as a file 14 | ```js 15 | // styles.js 16 | require('a.css'); 17 | require('b.css'); 18 | 19 | // webpack.config.js 20 | module.exports = { 21 | entry: { 22 | 'common.styles' : 'styles.js' 23 | } 24 | } 25 | ``` 26 | > :warning: CSS dependencies in a JS file are 1 level deep. It will not recursively check for dependencies, that are exclusively CSS, when requiring additional JS files. 27 | 28 | Example as an array 29 | ```js 30 | module.exports = { 31 | entry: { 32 | 'common.styles' : [ 33 | 'a.css', 34 | 'b.css' 35 | ] 36 | } 37 | } 38 | ``` 39 | In both examples Webpack would output: 40 | `` common.styles.js (Not Needed)`` 41 | ``common.styles.css`` 42 | 43 | 44 | ## Installation 45 | ```bash 46 | // For Webpack v4.x 47 | npm install --save-dev webpack-omit-js-for-css-plugin 48 | 49 | // For Webpack v3.x 50 | npm install --save-dev webpack-omit-js-for-css-plugin@2.0.0 51 | ``` 52 | ## Usage 53 | 54 | ```js 55 | const OmitJSforCSSPlugin = require("webpack-omit-js-for-css-plugin"); 56 | 57 | module.exports = { 58 | plugins: [ 59 | new OmitJSforCSSPlugin() 60 | ] 61 | } 62 | ``` 63 | > Note: [MiniCssExtractPlugin](https://github.com/webpack-contrib/mini-css-extract-plugin "MiniCssExtractPlugin") is a Peer Dependency. You will need to configure that as you normally would in your webpack.config.js 64 | 65 | ## Options 66 | ```js 67 | new OmitJSforCSSPlugin(options: object) 68 | ``` 69 | |Name|Type|Default|Description| 70 | |:--:|:--:|:-----:|:----------| 71 | |**`preview`**|`{Boolean}`|false|Will display a preview of the files that are to be omitted in the console (Will not actually omit)| 72 | |**`verbose`**|`{Boolean}`|false|Whether it should display which files will be omitted to the console| 73 | 74 | ## :fire: Additional Notes :fire: 75 | It is highly recommended you only include this plugin when you're building for production. -------------------------------------------------------------------------------- /__tests__/css-entry-array.test.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const path = require('path'); 3 | const rimraf = require('rimraf'); 4 | const options = require('./fixtures/css-array-entry/webpack.config.js'); 5 | const optionsSass = require('./fixtures/css-array-entry/webpack.config.sass.js'); 6 | const optionsLess = require('./fixtures/css-array-entry/webpack.config.less.js'); 7 | const dirPath = path.join(__dirname, './fixtures/css-array-entry/dir'); 8 | const fileShouldNotExist = require('./utils/file-should-not-exist.js'); 9 | const chunkShouldNotContainFile = require('./utils/chunk-should-not-contain-file.js'); 10 | 11 | describe('Array of CSS Dependencies as Entry', () => { 12 | beforeEach(done => { 13 | rimraf(dirPath, () => { 14 | done(); 15 | }); 16 | }); 17 | 18 | it('JS entry should not exist', done => { 19 | webpack(options, (err, stats) => { 20 | fileShouldNotExist(dirPath, '/a.js'); 21 | chunkShouldNotContainFile(stats, 'a', 'a.js'); 22 | done(); 23 | }); 24 | }); 25 | 26 | it('JS entry source map should not exist', done => { 27 | const optionSourceMap = Object.assign({}, options); 28 | optionSourceMap.devtool = 'source-map'; 29 | 30 | webpack(optionSourceMap, (err, stats) => { 31 | fileShouldNotExist(dirPath, '/a.js.map'); 32 | chunkShouldNotContainFile(stats, 'a', 'a.js.map'); 33 | done(); 34 | }); 35 | }); 36 | 37 | it('JS entry should not exist w/ sass', done => { 38 | webpack(optionsSass, (err, stats) => { 39 | fileShouldNotExist(dirPath, '/s.js'); 40 | chunkShouldNotContainFile(stats, 's', 's.js'); 41 | done(); 42 | }); 43 | }); 44 | 45 | it('JS entry source map should not exist w/ sass', done => { 46 | const optionSourceMap = Object.assign({}, optionsSass); 47 | optionSourceMap.devtool = 'source-map'; 48 | 49 | webpack(optionSourceMap, (err, stats) => { 50 | fileShouldNotExist(dirPath, '/s.js.map'); 51 | chunkShouldNotContainFile(stats, 's', 's.js.map'); 52 | done(); 53 | }); 54 | }); 55 | 56 | it('JS entry should not exist w/ less', done => { 57 | webpack(optionsLess, (err, stats) => { 58 | fileShouldNotExist(dirPath, '/l.js'); 59 | chunkShouldNotContainFile(stats, 'l', 'l.js'); 60 | done(); 61 | }); 62 | }); 63 | 64 | it('JS entry source map should not exist w/ less', done => { 65 | const optionSourceMap = Object.assign({}, optionsLess); 66 | optionSourceMap.devtool = 'source-map'; 67 | 68 | webpack(optionSourceMap, (err, stats) => { 69 | fileShouldNotExist(dirPath, '/l.js.map'); 70 | chunkShouldNotContainFile(stats, 'l', 'l.js.map'); 71 | done(); 72 | }); 73 | }); 74 | }); 75 | -------------------------------------------------------------------------------- /__tests__/fixtures/css-array-entry/dir/l.css: -------------------------------------------------------------------------------- 1 | #header { 2 | color: #6c94be; 3 | } 4 | 5 | .duck { 6 | color: yellow; 7 | } 8 | 9 | 10 | /*# sourceMappingURL=l.css.map*/ -------------------------------------------------------------------------------- /__tests__/fixtures/css-array-entry/dir/l.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///./__tests__/fixtures/css-array-entry/one.less","webpack:///./__tests__/fixtures/css-array-entry/two.less"],"names":[],"mappings":"AAAA;AACA;AACA;;ACFA;AACA;AACA","file":"l.css","sourcesContent":["#header {\n color: #6c94be;\n}\n",".duck {\n color: yellow;\n}\n"],"sourceRoot":""} -------------------------------------------------------------------------------- /__tests__/fixtures/css-array-entry/one.css: -------------------------------------------------------------------------------- 1 | .one { color : red; } -------------------------------------------------------------------------------- /__tests__/fixtures/css-array-entry/one.less: -------------------------------------------------------------------------------- 1 | @nice-blue: #5B83AD; 2 | @light-blue: @nice-blue + #111; 3 | 4 | #header { 5 | color: @light-blue; 6 | } -------------------------------------------------------------------------------- /__tests__/fixtures/css-array-entry/three.sass: -------------------------------------------------------------------------------- 1 | $font-stack: Helvetica, sans-serif 2 | $primary-color: #333 3 | 4 | body 5 | font: 100% $font-stack 6 | color: $primary-color 7 | -------------------------------------------------------------------------------- /__tests__/fixtures/css-array-entry/two.css: -------------------------------------------------------------------------------- 1 | .two { color : blue; } -------------------------------------------------------------------------------- /__tests__/fixtures/css-array-entry/two.less: -------------------------------------------------------------------------------- 1 | @nice-yellow: yellow; 2 | 3 | .duck { 4 | color: @nice-yellow; 5 | } -------------------------------------------------------------------------------- /__tests__/fixtures/css-array-entry/two.scss: -------------------------------------------------------------------------------- 1 | $font-stack: Helvetica, sans-serif; 2 | $primary-color: #333; 3 | 4 | body { 5 | font: 100% $font-stack; 6 | color: $primary-color; 7 | } 8 | 9 | .green { 10 | color : green; 11 | } -------------------------------------------------------------------------------- /__tests__/fixtures/css-array-entry/webpack.config.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | a: [path.join(__dirname, 'one.css'), path.join(__dirname, 'two.css')] 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader' 20 | ] 21 | } 22 | ] 23 | }, 24 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()], 25 | mode : 'development', 26 | devtool: 'source-map', 27 | stats: 'none' 28 | }; 29 | -------------------------------------------------------------------------------- /__tests__/fixtures/css-array-entry/webpack.config.less.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | l: [path.join(__dirname, 'one.less'), path.join(__dirname, 'two.less')] 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.(less)$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader', 20 | 'less-loader' 21 | ] 22 | } 23 | ] 24 | }, 25 | mode: 'development', 26 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()], 27 | stats: 'none' 28 | }; 29 | -------------------------------------------------------------------------------- /__tests__/fixtures/css-array-entry/webpack.config.sass.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | s: [path.join(__dirname, 'two.scss'), path.join(__dirname, 'three.sass')] 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.(scss|sass)$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader', 20 | 'sass-loader' 21 | ] 22 | } 23 | ] 24 | }, 25 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()], 26 | mode : 'development', 27 | devtool: 'source-map', 28 | stats: 'none' 29 | }; 30 | -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/one.css: -------------------------------------------------------------------------------- 1 | .one { color : red; } -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/one.less: -------------------------------------------------------------------------------- 1 | @nice-blue: #5B83AD; 2 | @light-blue: @nice-blue + #111; 3 | 4 | #header { 5 | color: @light-blue; 6 | } -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/styles-less.js: -------------------------------------------------------------------------------- 1 | require('./one.less'); 2 | require('./two.less'); -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/styles-sass.js: -------------------------------------------------------------------------------- 1 | require('./two.scss'); 2 | require('./three.sass'); -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/styles.js: -------------------------------------------------------------------------------- 1 | require('./one.css'); 2 | require('./two.css'); -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/three.sass: -------------------------------------------------------------------------------- 1 | $font-stack: Helvetica, sans-serif 2 | $primary-color: #333 3 | 4 | body 5 | font: 100% $font-stack 6 | color: $primary-color 7 | -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/two.css: -------------------------------------------------------------------------------- 1 | .two { color : blue; } -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/two.less: -------------------------------------------------------------------------------- 1 | @nice-yellow: yellow; 2 | 3 | .duck { 4 | color: @nice-yellow; 5 | } -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/two.scss: -------------------------------------------------------------------------------- 1 | $font-stack: Helvetica, sans-serif; 2 | $primary-color: #333; 3 | 4 | body { 5 | font: 100% $font-stack; 6 | color: $primary-color; 7 | } 8 | 9 | .green { 10 | color : green; 11 | } -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/webpack.config.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | b: path.join(__dirname, 'styles.js') 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader' 20 | ] 21 | } 22 | ] 23 | }, 24 | mode : 'development', 25 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()], 26 | stats: 'none' 27 | }; 28 | -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/webpack.config.less.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | l: path.join(__dirname, 'styles-less.js') 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.(less)$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader', 20 | 'less-loader' 21 | ] 22 | } 23 | ] 24 | }, 25 | mode: 'development', 26 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()], 27 | stats: 'none' 28 | }; 29 | -------------------------------------------------------------------------------- /__tests__/fixtures/js-file-entry/webpack.config.sass.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | s: path.join(__dirname, 'styles-sass.js') 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.(scss|sass)$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader', 20 | 'sass-loader' 21 | ] 22 | } 23 | ] 24 | }, 25 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()], 26 | mode : 'development', 27 | devtool: 'source-map', 28 | stats: 'none' 29 | }; 30 | -------------------------------------------------------------------------------- /__tests__/fixtures/options/preview/dir/b.css: -------------------------------------------------------------------------------- 1 | .one { color : red; } 2 | .two { color : blue; } 3 | 4 | /*# sourceMappingURL=b.css.map*/ -------------------------------------------------------------------------------- /__tests__/fixtures/options/preview/dir/b.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///./__tests__/fixtures/options/shared/one.css","webpack:///./__tests__/fixtures/options/shared/two.css"],"names":[],"mappings":"AAAA,MAAM,aAAa,E;ACAnB,MAAM,cAAc,E","file":"b.css","sourcesContent":[".one { color : red; }",".two { color : blue; }"],"sourceRoot":""} -------------------------------------------------------------------------------- /__tests__/fixtures/options/preview/dir/b.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | /******/ 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | /******/ 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) { 10 | /******/ return installedModules[moduleId].exports; 11 | /******/ } 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ i: moduleId, 15 | /******/ l: false, 16 | /******/ exports: {} 17 | /******/ }; 18 | /******/ 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | /******/ 22 | /******/ // Flag the module as loaded 23 | /******/ module.l = true; 24 | /******/ 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | /******/ 29 | /******/ 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | /******/ 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | /******/ 36 | /******/ // define getter function for harmony exports 37 | /******/ __webpack_require__.d = function(exports, name, getter) { 38 | /******/ if(!__webpack_require__.o(exports, name)) { 39 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 40 | /******/ } 41 | /******/ }; 42 | /******/ 43 | /******/ // define __esModule on exports 44 | /******/ __webpack_require__.r = function(exports) { 45 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47 | /******/ } 48 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 49 | /******/ }; 50 | /******/ 51 | /******/ // create a fake namespace object 52 | /******/ // mode & 1: value is a module id, require it 53 | /******/ // mode & 2: merge all properties of value into the ns 54 | /******/ // mode & 4: return value when already ns object 55 | /******/ // mode & 8|1: behave like require 56 | /******/ __webpack_require__.t = function(value, mode) { 57 | /******/ if(mode & 1) value = __webpack_require__(value); 58 | /******/ if(mode & 8) return value; 59 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60 | /******/ var ns = Object.create(null); 61 | /******/ __webpack_require__.r(ns); 62 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64 | /******/ return ns; 65 | /******/ }; 66 | /******/ 67 | /******/ // getDefaultExport function for compatibility with non-harmony modules 68 | /******/ __webpack_require__.n = function(module) { 69 | /******/ var getter = module && module.__esModule ? 70 | /******/ function getDefault() { return module['default']; } : 71 | /******/ function getModuleExports() { return module; }; 72 | /******/ __webpack_require__.d(getter, 'a', getter); 73 | /******/ return getter; 74 | /******/ }; 75 | /******/ 76 | /******/ // Object.prototype.hasOwnProperty.call 77 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78 | /******/ 79 | /******/ // __webpack_public_path__ 80 | /******/ __webpack_require__.p = ""; 81 | /******/ 82 | /******/ 83 | /******/ // Load entry module and return exports 84 | /******/ return __webpack_require__(__webpack_require__.s = "./__tests__/fixtures/options/shared/styles.js"); 85 | /******/ }) 86 | /************************************************************************/ 87 | /******/ ({ 88 | 89 | /***/ "./__tests__/fixtures/options/shared/one.css": 90 | /*!***************************************************!*\ 91 | !*** ./__tests__/fixtures/options/shared/one.css ***! 92 | \***************************************************/ 93 | /*! no static exports found */ 94 | /***/ (function(module, exports, __webpack_require__) { 95 | 96 | // extracted by mini-css-extract-plugin 97 | 98 | /***/ }), 99 | 100 | /***/ "./__tests__/fixtures/options/shared/styles.js": 101 | /*!*****************************************************!*\ 102 | !*** ./__tests__/fixtures/options/shared/styles.js ***! 103 | \*****************************************************/ 104 | /*! no static exports found */ 105 | /***/ (function(module, exports, __webpack_require__) { 106 | 107 | __webpack_require__(/*! ./one.css */ "./__tests__/fixtures/options/shared/one.css"); 108 | __webpack_require__(/*! ./two.css */ "./__tests__/fixtures/options/shared/two.css"); 109 | 110 | 111 | /***/ }), 112 | 113 | /***/ "./__tests__/fixtures/options/shared/two.css": 114 | /*!***************************************************!*\ 115 | !*** ./__tests__/fixtures/options/shared/two.css ***! 116 | \***************************************************/ 117 | /*! no static exports found */ 118 | /***/ (function(module, exports, __webpack_require__) { 119 | 120 | // extracted by mini-css-extract-plugin 121 | 122 | /***/ }) 123 | 124 | /******/ }); 125 | //# sourceMappingURL=b.js.map -------------------------------------------------------------------------------- /__tests__/fixtures/options/preview/dir/b.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./__tests__/fixtures/options/shared/one.css?ff25","webpack:///./__tests__/fixtures/options/shared/styles.js","webpack:///./__tests__/fixtures/options/shared/two.css?b23e"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;AClFA,uC;;;;;;;;;;;ACAA,mBAAO,CAAC,8DAAW;AACnB,mBAAO,CAAC,8DAAW;;;;;;;;;;;;ACDnB,uC","file":"b.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./__tests__/fixtures/options/shared/styles.js\");\n","// extracted by mini-css-extract-plugin","require('./one.css');\nrequire('./two.css');\n","// extracted by mini-css-extract-plugin"],"sourceRoot":""} -------------------------------------------------------------------------------- /__tests__/fixtures/options/preview/webpack.config.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | b: path.join(__dirname, '../shared/styles.js') 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader' 20 | ] 21 | } 22 | ] 23 | }, 24 | mode: 'development', 25 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin({ preview: true })], 26 | devtool: 'source-map', 27 | stats: 'none' 28 | }; 29 | -------------------------------------------------------------------------------- /__tests__/fixtures/options/shared/one.css: -------------------------------------------------------------------------------- 1 | .one { color : red; } -------------------------------------------------------------------------------- /__tests__/fixtures/options/shared/styles.js: -------------------------------------------------------------------------------- 1 | require('./one.css'); 2 | require('./two.css'); 3 | -------------------------------------------------------------------------------- /__tests__/fixtures/options/shared/three.css: -------------------------------------------------------------------------------- 1 | .three { color : green; } -------------------------------------------------------------------------------- /__tests__/fixtures/options/shared/two.css: -------------------------------------------------------------------------------- 1 | .two { color : blue; } -------------------------------------------------------------------------------- /__tests__/fixtures/options/verbose/dir/b.css: -------------------------------------------------------------------------------- 1 | .one { color : red; } 2 | .two { color : blue; } 3 | 4 | /*# sourceMappingURL=b.css.map*/ -------------------------------------------------------------------------------- /__tests__/fixtures/options/verbose/dir/b.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///./__tests__/fixtures/options/shared/one.css","webpack:///./__tests__/fixtures/options/shared/two.css"],"names":[],"mappings":"AAAA,MAAM,aAAa,E;ACAnB,MAAM,cAAc,E","file":"b.css","sourcesContent":[".one { color : red; }",".two { color : blue; }"],"sourceRoot":""} -------------------------------------------------------------------------------- /__tests__/fixtures/options/verbose/webpack.config.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | b: path.join(__dirname, '../shared/styles.js') 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader' 20 | ] 21 | } 22 | ] 23 | }, 24 | mode : 'development', 25 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin({ verbose: true })], 26 | devtool: 'source-map', 27 | stats: 'none' 28 | }; 29 | -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/external-dep/webpack.config.arr.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | e: ['chalk', 'path'] 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader' 20 | ] 21 | } 22 | ] 23 | }, 24 | mode : 'development', 25 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()], 26 | stats: 'none', 27 | devtool: 'source-map' 28 | }; 29 | -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/external-dep/webpack.config.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | c: path.join(__dirname, '../shared/colorful.js') 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader' 20 | ] 21 | } 22 | ] 23 | }, 24 | mode : 'development', 25 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()], 26 | stats: 'none', 27 | devtool: 'source-map' 28 | }; 29 | -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/external-internal/dir/j.css: -------------------------------------------------------------------------------- 1 | .one { color : red; } 2 | 3 | /*# sourceMappingURL=j.css.map*/ -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/external-internal/dir/j.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///./__tests__/fixtures/should-not-omit/shared/one.css"],"names":[],"mappings":"AAAA,MAAM,aAAa,E","file":"j.css","sourcesContent":[".one { color : red; }"],"sourceRoot":""} -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/external-internal/dir/j.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | /******/ 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | /******/ 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) { 10 | /******/ return installedModules[moduleId].exports; 11 | /******/ } 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ i: moduleId, 15 | /******/ l: false, 16 | /******/ exports: {} 17 | /******/ }; 18 | /******/ 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | /******/ 22 | /******/ // Flag the module as loaded 23 | /******/ module.l = true; 24 | /******/ 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | /******/ 29 | /******/ 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | /******/ 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | /******/ 36 | /******/ // define getter function for harmony exports 37 | /******/ __webpack_require__.d = function(exports, name, getter) { 38 | /******/ if(!__webpack_require__.o(exports, name)) { 39 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 40 | /******/ } 41 | /******/ }; 42 | /******/ 43 | /******/ // define __esModule on exports 44 | /******/ __webpack_require__.r = function(exports) { 45 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47 | /******/ } 48 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 49 | /******/ }; 50 | /******/ 51 | /******/ // create a fake namespace object 52 | /******/ // mode & 1: value is a module id, require it 53 | /******/ // mode & 2: merge all properties of value into the ns 54 | /******/ // mode & 4: return value when already ns object 55 | /******/ // mode & 8|1: behave like require 56 | /******/ __webpack_require__.t = function(value, mode) { 57 | /******/ if(mode & 1) value = __webpack_require__(value); 58 | /******/ if(mode & 8) return value; 59 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60 | /******/ var ns = Object.create(null); 61 | /******/ __webpack_require__.r(ns); 62 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64 | /******/ return ns; 65 | /******/ }; 66 | /******/ 67 | /******/ // getDefaultExport function for compatibility with non-harmony modules 68 | /******/ __webpack_require__.n = function(module) { 69 | /******/ var getter = module && module.__esModule ? 70 | /******/ function getDefault() { return module['default']; } : 71 | /******/ function getModuleExports() { return module; }; 72 | /******/ __webpack_require__.d(getter, 'a', getter); 73 | /******/ return getter; 74 | /******/ }; 75 | /******/ 76 | /******/ // Object.prototype.hasOwnProperty.call 77 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78 | /******/ 79 | /******/ // __webpack_public_path__ 80 | /******/ __webpack_require__.p = ""; 81 | /******/ 82 | /******/ 83 | /******/ // Load entry module and return exports 84 | /******/ return __webpack_require__(__webpack_require__.s = 0); 85 | /******/ }) 86 | /************************************************************************/ 87 | /******/ ({ 88 | 89 | /***/ "./__tests__/fixtures/should-not-omit/shared/one.css": 90 | /*!***********************************************************!*\ 91 | !*** ./__tests__/fixtures/should-not-omit/shared/one.css ***! 92 | \***********************************************************/ 93 | /*! no static exports found */ 94 | /***/ (function(module, exports, __webpack_require__) { 95 | 96 | // extracted by mini-css-extract-plugin 97 | 98 | /***/ }), 99 | 100 | /***/ "./node_modules/preact/dist/preact.module.js": 101 | /*!***************************************************!*\ 102 | !*** ./node_modules/preact/dist/preact.module.js ***! 103 | \***************************************************/ 104 | /*! exports provided: render, hydrate, createElement, h, Fragment, createRef, isValidElement, Component, cloneElement, createContext, toChildArray, _unmount, options */ 105 | /***/ (function(module, __webpack_exports__, __webpack_require__) { 106 | 107 | "use strict"; 108 | __webpack_require__.r(__webpack_exports__); 109 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return E; }); 110 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hydrate", function() { return H; }); 111 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createElement", function() { return v; }); 112 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return v; }); 113 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Fragment", function() { return d; }); 114 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createRef", function() { return p; }); 115 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidElement", function() { return l; }); 116 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Component", function() { return y; }); 117 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cloneElement", function() { return I; }); 118 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createContext", function() { return L; }); 119 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toChildArray", function() { return b; }); 120 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_unmount", function() { return A; }); 121 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "options", function() { return n; }); 122 | var n,l,u,i,t,o,r,f={},e=[],c=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;function s(n,l){for(var u in l)n[u]=l[u];return n}function a(n){var l=n.parentNode;l&&l.removeChild(n)}function v(n,l,u){var i,t=arguments,o={};for(i in l)"key"!==i&&"ref"!==i&&(o[i]=l[i]);if(arguments.length>3)for(u=[u],i=3;i2&&(l.children=e.slice.call(arguments,2)),h(n.type,l,l.key||n.key,l.ref||n.ref)}function L(n){var l={},u={__c:"__cC"+r++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var i,t=this;return this.getChildContext||(i=[],this.getChildContext=function(){return l[u.__c]=t,l},this.shouldComponentUpdate=function(l){n.value!==l.value&&i.some(function(n){n.context=l.value,g(n)})},this.sub=function(n){i.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){i.splice(i.indexOf(n),1),l&&l.call(n)}}),n.children}};return u.Consumer.contextType=u,u}n={__e:function(n,l){for(var u,i;l=l.__;)if((u=l.__c)&&!u.__)try{if(u.constructor&&null!=u.constructor.getDerivedStateFromError&&(i=!0,u.setState(u.constructor.getDerivedStateFromError(n))),null!=u.componentDidCatch&&(i=!0,u.componentDidCatch(n)),i)return g(u.__E=u)}catch(l){n=l}throw n}},l=function(n){return null!=n&&void 0===n.constructor},y.prototype.setState=function(n,l){var u;u=this.__s!==this.state?this.__s:this.__s=s({},this.state),"function"==typeof n&&(n=n(u,this.props)),n&&s(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),g(this))},y.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),g(this))},y.prototype.render=d,u=[],i="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,o=f,r=0; 123 | //# sourceMappingURL=preact.module.js.map 124 | 125 | 126 | /***/ }), 127 | 128 | /***/ 0: 129 | /*!************************************************************************!*\ 130 | !*** multi preact ./__tests__/fixtures/should-not-omit/shared/one.css ***! 131 | \************************************************************************/ 132 | /*! no static exports found */ 133 | /***/ (function(module, exports, __webpack_require__) { 134 | 135 | __webpack_require__(/*! preact */"./node_modules/preact/dist/preact.module.js"); 136 | module.exports = __webpack_require__(/*! /Users/jsilva/Documents/htdocs/webpack-omit-js-for-css-plugin/__tests__/fixtures/should-not-omit/shared/one.css */"./__tests__/fixtures/should-not-omit/shared/one.css"); 137 | 138 | 139 | /***/ }) 140 | 141 | /******/ }); 142 | //# sourceMappingURL=j.js.map -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/external-internal/dir/j.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./__tests__/fixtures/should-not-omit/shared/one.css?aa36","webpack:///./node_modules/preact/dist/preact.module.js"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;AClFA,uC;;;;;;;;;;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAsB,sEAAsE,gBAAgB,yBAAyB,SAAS,cAAc,mBAAmB,oBAAoB,kBAAkB,uBAAuB,6CAA6C,oCAAoC,mBAAmB,iBAAiB,sIAAsI,gCAAgC,oBAAoB,OAAO,mGAAmG,6BAA6B,aAAa,SAAS,cAAc,kBAAkB,gBAAgB,4BAA4B,gBAAgB,0DAA0D,UAAU,eAAe,oDAAoD,0CAA0C,cAAc,QAAQ,gCAAgC,8BAA8B,eAAe,wCAAwC,uBAAuB,MAAM,aAAa,cAAc,8FAA8F,aAAa,kBAAkB,yBAAyB,2BAA2B,EAAE,UAAU,4EAA4E,gFAAgF,8BAA8B,2CAA2C,sEAAsE,YAAY,sFAAsF,aAAa,IAAI,KAAK,4CAA4C,YAAY,MAAM,OAAO,0HAA0H,MAAM,sDAAsD,wCAAwC,uDAAuD,KAAK,YAAY,uBAAuB,qBAAqB,wBAAwB,+BAA+B,mEAAmE,aAAa,4DAA4D,IAAI,qBAAqB,QAAQ,IAAI,0BAA0B,aAAa,WAAW,0BAA0B,kBAAkB,mEAAmE,qCAAqC,WAAW,gBAAgB,uIAAuI,SAAS,sBAAsB,MAAM,sCAAsC,mGAAmG,kBAAkB,0FAA0F,sBAAsB,cAAc,0FAA0F,gEAAgE,KAAK,+EAA+E,4CAA4C,sJAAsJ,2aAA2a,cAAc,qCAAqC,8BAA8B,iCAAiC,sCAAsC,gBAAgB,IAAI,2BAA2B,yPAAyP,sIAAsI,6NAA6N,KAAK,gMAAgM,iGAAiG,eAAe,8BAA8B,QAAQ,gHAAgH,4BAA4B,EAAE,8MAA8M,yLAAyL,kCAAkC,mBAAmB,SAAS,aAAa,aAAa,gBAAgB,qCAAqC,IAAI,oCAAoC,UAAU,EAAE,SAAS,gBAAgB,EAAE,4BAA4B,kCAAkC,gDAAgD,WAAW,4EAA4E,cAAc,MAAM,YAAY,mDAAmD,uGAAuG,QAAQ,SAAS,8EAA8E,eAAe,yIAAyI,iBAAiB,KAAK,sBAAsB,kDAAkD,kEAAkE,gQAAgQ,SAAS,kBAAkB,IAAI,sCAAsC,SAAS,YAAY,kBAAkB,UAAU,wKAAwK,8BAA8B,yBAAyB,SAAS,WAAW,kBAAkB,mBAAmB,WAAW,sBAAsB,cAAc,kBAAkB,6BAA6B,kBAAkB,UAAU,0LAA0L,gBAAgB,SAAS,gBAAgB,eAAe,8GAA8G,cAAc,QAAQ,IAAI,2CAA2C,qBAAqB,sBAAsB,aAAa,mEAAmE,oBAAoB,wCAAwC,sCAAsC,uBAAuB,EAAE,sBAAsB,UAAU,6BAA6B,kCAAkC,uCAAuC,eAAe,kCAAkC,GAAG,kBAAkB,YAAY,OAAO,yBAAyB,0MAA0M,SAAS,IAAI,SAAS,eAAe,uCAAuC,oCAAoC,MAAM,8CAA8C,kHAAkH,qCAAqC,oDAAoD,0HAAuU;AACxgS","file":"j.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","// extracted by mini-css-extract-plugin","var n,l,u,i,t,o,r,f={},e=[],c=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;function s(n,l){for(var u in l)n[u]=l[u];return n}function a(n){var l=n.parentNode;l&&l.removeChild(n)}function v(n,l,u){var i,t=arguments,o={};for(i in l)\"key\"!==i&&\"ref\"!==i&&(o[i]=l[i]);if(arguments.length>3)for(u=[u],i=3;i2&&(l.children=e.slice.call(arguments,2)),h(n.type,l,l.key||n.key,l.ref||n.ref)}function L(n){var l={},u={__c:\"__cC\"+r++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var i,t=this;return this.getChildContext||(i=[],this.getChildContext=function(){return l[u.__c]=t,l},this.shouldComponentUpdate=function(l){n.value!==l.value&&i.some(function(n){n.context=l.value,g(n)})},this.sub=function(n){i.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){i.splice(i.indexOf(n),1),l&&l.call(n)}}),n.children}};return u.Consumer.contextType=u,u}n={__e:function(n,l){for(var u,i;l=l.__;)if((u=l.__c)&&!u.__)try{if(u.constructor&&null!=u.constructor.getDerivedStateFromError&&(i=!0,u.setState(u.constructor.getDerivedStateFromError(n))),null!=u.componentDidCatch&&(i=!0,u.componentDidCatch(n)),i)return g(u.__E=u)}catch(l){n=l}throw n}},l=function(n){return null!=n&&void 0===n.constructor},y.prototype.setState=function(n,l){var u;u=this.__s!==this.state?this.__s:this.__s=s({},this.state),\"function\"==typeof n&&(n=n(u,this.props)),n&&s(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),g(this))},y.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),g(this))},y.prototype.render=d,u=[],i=\"function\"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,o=f,r=0;export{E as render,H as hydrate,v as createElement,v as h,d as Fragment,p as createRef,l as isValidElement,y as Component,I as cloneElement,L as createContext,b as toChildArray,A as _unmount,n as options};\n//# sourceMappingURL=preact.module.js.map\n"],"sourceRoot":""} -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/external-internal/extin-entry.js: -------------------------------------------------------------------------------- 1 | require('.../shared/one.css'); 2 | require('../shared/two.css'); 3 | const preact = require('preact'); 4 | preact.render(preact.h('div', null, 'hello'), document.body); -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/external-internal/webpack.config.arr.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | j: ['preact', path.join(__dirname, '..', '/shared/one.css')] 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader' 20 | ] 21 | } 22 | ] 23 | }, 24 | mode : 'development', 25 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin({verbose : true})], 26 | stats: 'none', 27 | devtool: 'source-map' 28 | }; 29 | -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/external-internal/webpack.config.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | f: path.join(__dirname, './extin-entry.js') 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader' 20 | ] 21 | } 22 | ] 23 | }, 24 | mode : 'development', 25 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()], 26 | stats: 'none', 27 | devtool: 'source-map' 28 | }; 29 | -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/internal-dep/dir/b.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | /******/ 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | /******/ 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) { 10 | /******/ return installedModules[moduleId].exports; 11 | /******/ } 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ i: moduleId, 15 | /******/ l: false, 16 | /******/ exports: {} 17 | /******/ }; 18 | /******/ 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | /******/ 22 | /******/ // Flag the module as loaded 23 | /******/ module.l = true; 24 | /******/ 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | /******/ 29 | /******/ 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | /******/ 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | /******/ 36 | /******/ // define getter function for harmony exports 37 | /******/ __webpack_require__.d = function(exports, name, getter) { 38 | /******/ if(!__webpack_require__.o(exports, name)) { 39 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 40 | /******/ } 41 | /******/ }; 42 | /******/ 43 | /******/ // define __esModule on exports 44 | /******/ __webpack_require__.r = function(exports) { 45 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47 | /******/ } 48 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 49 | /******/ }; 50 | /******/ 51 | /******/ // create a fake namespace object 52 | /******/ // mode & 1: value is a module id, require it 53 | /******/ // mode & 2: merge all properties of value into the ns 54 | /******/ // mode & 4: return value when already ns object 55 | /******/ // mode & 8|1: behave like require 56 | /******/ __webpack_require__.t = function(value, mode) { 57 | /******/ if(mode & 1) value = __webpack_require__(value); 58 | /******/ if(mode & 8) return value; 59 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60 | /******/ var ns = Object.create(null); 61 | /******/ __webpack_require__.r(ns); 62 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64 | /******/ return ns; 65 | /******/ }; 66 | /******/ 67 | /******/ // getDefaultExport function for compatibility with non-harmony modules 68 | /******/ __webpack_require__.n = function(module) { 69 | /******/ var getter = module && module.__esModule ? 70 | /******/ function getDefault() { return module['default']; } : 71 | /******/ function getModuleExports() { return module; }; 72 | /******/ __webpack_require__.d(getter, 'a', getter); 73 | /******/ return getter; 74 | /******/ }; 75 | /******/ 76 | /******/ // Object.prototype.hasOwnProperty.call 77 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78 | /******/ 79 | /******/ // __webpack_public_path__ 80 | /******/ __webpack_require__.p = ""; 81 | /******/ 82 | /******/ 83 | /******/ // Load entry module and return exports 84 | /******/ return __webpack_require__(__webpack_require__.s = "./__tests__/fixtures/should-not-omit/shared/common.js"); 85 | /******/ }) 86 | /************************************************************************/ 87 | /******/ ({ 88 | 89 | /***/ "./__tests__/fixtures/should-not-omit/shared/common.js": 90 | /*!*************************************************************!*\ 91 | !*** ./__tests__/fixtures/should-not-omit/shared/common.js ***! 92 | \*************************************************************/ 93 | /*! no static exports found */ 94 | /***/ (function(module, exports, __webpack_require__) { 95 | 96 | const one = __webpack_require__(/*! ./one.js */ "./__tests__/fixtures/should-not-omit/shared/one.js"); 97 | 98 | module.exports = function(){ 99 | return one + 2; 100 | }; 101 | 102 | /***/ }), 103 | 104 | /***/ "./__tests__/fixtures/should-not-omit/shared/one.js": 105 | /*!**********************************************************!*\ 106 | !*** ./__tests__/fixtures/should-not-omit/shared/one.js ***! 107 | \**********************************************************/ 108 | /*! no static exports found */ 109 | /***/ (function(module, exports) { 110 | 111 | module.exports = function (){ 112 | return 1; 113 | }; 114 | 115 | /***/ }) 116 | 117 | /******/ }); 118 | //# sourceMappingURL=b.js.map -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/internal-dep/dir/b.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./__tests__/fixtures/should-not-omit/shared/common.js","webpack:///./__tests__/fixtures/should-not-omit/shared/one.js"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;AClFA,YAAY,mBAAO,CAAC,oEAAU;;AAE9B;AACA;AACA,E;;;;;;;;;;;ACJA;AACA;AACA,E","file":"b.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./__tests__/fixtures/should-not-omit/shared/common.js\");\n","const one = require('./one.js');\n\nmodule.exports = function(){\n\treturn one + 2;\n};","module.exports = function (){\n\treturn 1;\n};"],"sourceRoot":""} -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/internal-dep/webpack.config.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | b: path.join(__dirname, '../shared/common.js') 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader' 20 | ] 21 | } 22 | ] 23 | }, 24 | mode : 'development', 25 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()], 26 | stats: 'none', 27 | devtool: 'source-map' 28 | }; 29 | -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/mixed-dep/dir/d.css: -------------------------------------------------------------------------------- 1 | .one { color : red; } 2 | .two { color : blue; } 3 | 4 | /*# sourceMappingURL=d.css.map*/ -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/mixed-dep/dir/d.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///./__tests__/fixtures/should-not-omit/shared/one.css","webpack:///./__tests__/fixtures/should-not-omit/shared/two.css"],"names":[],"mappings":"AAAA,MAAM,aAAa,E;ACAnB,MAAM,cAAc,E","file":"d.css","sourcesContent":[".one { color : red; }",".two { color : blue; }"],"sourceRoot":""} -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/mixed-dep/dir/d.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | /******/ 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | /******/ 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) { 10 | /******/ return installedModules[moduleId].exports; 11 | /******/ } 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ i: moduleId, 15 | /******/ l: false, 16 | /******/ exports: {} 17 | /******/ }; 18 | /******/ 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | /******/ 22 | /******/ // Flag the module as loaded 23 | /******/ module.l = true; 24 | /******/ 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | /******/ 29 | /******/ 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | /******/ 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | /******/ 36 | /******/ // define getter function for harmony exports 37 | /******/ __webpack_require__.d = function(exports, name, getter) { 38 | /******/ if(!__webpack_require__.o(exports, name)) { 39 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 40 | /******/ } 41 | /******/ }; 42 | /******/ 43 | /******/ // define __esModule on exports 44 | /******/ __webpack_require__.r = function(exports) { 45 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47 | /******/ } 48 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 49 | /******/ }; 50 | /******/ 51 | /******/ // create a fake namespace object 52 | /******/ // mode & 1: value is a module id, require it 53 | /******/ // mode & 2: merge all properties of value into the ns 54 | /******/ // mode & 4: return value when already ns object 55 | /******/ // mode & 8|1: behave like require 56 | /******/ __webpack_require__.t = function(value, mode) { 57 | /******/ if(mode & 1) value = __webpack_require__(value); 58 | /******/ if(mode & 8) return value; 59 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60 | /******/ var ns = Object.create(null); 61 | /******/ __webpack_require__.r(ns); 62 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64 | /******/ return ns; 65 | /******/ }; 66 | /******/ 67 | /******/ // getDefaultExport function for compatibility with non-harmony modules 68 | /******/ __webpack_require__.n = function(module) { 69 | /******/ var getter = module && module.__esModule ? 70 | /******/ function getDefault() { return module['default']; } : 71 | /******/ function getModuleExports() { return module; }; 72 | /******/ __webpack_require__.d(getter, 'a', getter); 73 | /******/ return getter; 74 | /******/ }; 75 | /******/ 76 | /******/ // Object.prototype.hasOwnProperty.call 77 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78 | /******/ 79 | /******/ // __webpack_public_path__ 80 | /******/ __webpack_require__.p = ""; 81 | /******/ 82 | /******/ 83 | /******/ // Load entry module and return exports 84 | /******/ return __webpack_require__(__webpack_require__.s = "./__tests__/fixtures/should-not-omit/shared/mixed.js"); 85 | /******/ }) 86 | /************************************************************************/ 87 | /******/ ({ 88 | 89 | /***/ "./__tests__/fixtures/should-not-omit/shared/colorful.js": 90 | /*!***************************************************************!*\ 91 | !*** ./__tests__/fixtures/should-not-omit/shared/colorful.js ***! 92 | \***************************************************************/ 93 | /*! no static exports found */ 94 | /***/ (function(module, exports, __webpack_require__) { 95 | 96 | const chalk = __webpack_require__(/*! chalk */ "./node_modules/chalk/source/index.js"); 97 | chalk.green('color it green'); 98 | 99 | /***/ }), 100 | 101 | /***/ "./__tests__/fixtures/should-not-omit/shared/mixed.js": 102 | /*!************************************************************!*\ 103 | !*** ./__tests__/fixtures/should-not-omit/shared/mixed.js ***! 104 | \************************************************************/ 105 | /*! no static exports found */ 106 | /***/ (function(module, exports, __webpack_require__) { 107 | 108 | __webpack_require__(/*! ./colorful.js */ "./__tests__/fixtures/should-not-omit/shared/colorful.js"); 109 | __webpack_require__(/*! ./styles.js */ "./__tests__/fixtures/should-not-omit/shared/styles.js"); 110 | const one = __webpack_require__(/*! ./one.js */ "./__tests__/fixtures/should-not-omit/shared/one.js"); 111 | 112 | /***/ }), 113 | 114 | /***/ "./__tests__/fixtures/should-not-omit/shared/one.css": 115 | /*!***********************************************************!*\ 116 | !*** ./__tests__/fixtures/should-not-omit/shared/one.css ***! 117 | \***********************************************************/ 118 | /*! no static exports found */ 119 | /***/ (function(module, exports, __webpack_require__) { 120 | 121 | // extracted by mini-css-extract-plugin 122 | 123 | /***/ }), 124 | 125 | /***/ "./__tests__/fixtures/should-not-omit/shared/one.js": 126 | /*!**********************************************************!*\ 127 | !*** ./__tests__/fixtures/should-not-omit/shared/one.js ***! 128 | \**********************************************************/ 129 | /*! no static exports found */ 130 | /***/ (function(module, exports) { 131 | 132 | module.exports = function (){ 133 | return 1; 134 | }; 135 | 136 | /***/ }), 137 | 138 | /***/ "./__tests__/fixtures/should-not-omit/shared/styles.js": 139 | /*!*************************************************************!*\ 140 | !*** ./__tests__/fixtures/should-not-omit/shared/styles.js ***! 141 | \*************************************************************/ 142 | /*! no static exports found */ 143 | /***/ (function(module, exports, __webpack_require__) { 144 | 145 | __webpack_require__(/*! ./one.css */ "./__tests__/fixtures/should-not-omit/shared/one.css"); 146 | __webpack_require__(/*! ./two.css */ "./__tests__/fixtures/should-not-omit/shared/two.css"); 147 | 148 | /***/ }), 149 | 150 | /***/ "./__tests__/fixtures/should-not-omit/shared/two.css": 151 | /*!***********************************************************!*\ 152 | !*** ./__tests__/fixtures/should-not-omit/shared/two.css ***! 153 | \***********************************************************/ 154 | /*! no static exports found */ 155 | /***/ (function(module, exports, __webpack_require__) { 156 | 157 | // extracted by mini-css-extract-plugin 158 | 159 | /***/ }), 160 | 161 | /***/ "./node_modules/ansi-styles/index.js": 162 | /*!*******************************************!*\ 163 | !*** ./node_modules/ansi-styles/index.js ***! 164 | \*******************************************/ 165 | /*! no static exports found */ 166 | /***/ (function(module, exports, __webpack_require__) { 167 | 168 | "use strict"; 169 | /* WEBPACK VAR INJECTION */(function(module) { 170 | 171 | const wrapAnsi16 = (fn, offset) => (...args) => { 172 | const code = fn(...args); 173 | return `\u001B[${code + offset}m`; 174 | }; 175 | 176 | const wrapAnsi256 = (fn, offset) => (...args) => { 177 | const code = fn(...args); 178 | return `\u001B[${38 + offset};5;${code}m`; 179 | }; 180 | 181 | const wrapAnsi16m = (fn, offset) => (...args) => { 182 | const rgb = fn(...args); 183 | return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; 184 | }; 185 | 186 | const ansi2ansi = n => n; 187 | const rgb2rgb = (r, g, b) => [r, g, b]; 188 | 189 | const setLazyProperty = (object, property, get) => { 190 | Object.defineProperty(object, property, { 191 | get: () => { 192 | const value = get(); 193 | 194 | Object.defineProperty(object, property, { 195 | value, 196 | enumerable: true, 197 | configurable: true 198 | }); 199 | 200 | return value; 201 | }, 202 | enumerable: true, 203 | configurable: true 204 | }); 205 | }; 206 | 207 | /** @type {typeof import('color-convert')} */ 208 | let colorConvert; 209 | const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => { 210 | if (colorConvert === undefined) { 211 | colorConvert = __webpack_require__(/*! color-convert */ "./node_modules/color-convert/index.js"); 212 | } 213 | 214 | const offset = isBackground ? 10 : 0; 215 | const styles = {}; 216 | 217 | for (const [sourceSpace, suite] of Object.entries(colorConvert)) { 218 | const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace; 219 | if (sourceSpace === targetSpace) { 220 | styles[name] = wrap(identity, offset); 221 | } else if (typeof suite === 'object') { 222 | styles[name] = wrap(suite[targetSpace], offset); 223 | } 224 | } 225 | 226 | return styles; 227 | }; 228 | 229 | function assembleStyles() { 230 | const codes = new Map(); 231 | const styles = { 232 | modifier: { 233 | reset: [0, 0], 234 | // 21 isn't widely supported and 22 does the same thing 235 | bold: [1, 22], 236 | dim: [2, 22], 237 | italic: [3, 23], 238 | underline: [4, 24], 239 | inverse: [7, 27], 240 | hidden: [8, 28], 241 | strikethrough: [9, 29] 242 | }, 243 | color: { 244 | black: [30, 39], 245 | red: [31, 39], 246 | green: [32, 39], 247 | yellow: [33, 39], 248 | blue: [34, 39], 249 | magenta: [35, 39], 250 | cyan: [36, 39], 251 | white: [37, 39], 252 | 253 | // Bright color 254 | blackBright: [90, 39], 255 | redBright: [91, 39], 256 | greenBright: [92, 39], 257 | yellowBright: [93, 39], 258 | blueBright: [94, 39], 259 | magentaBright: [95, 39], 260 | cyanBright: [96, 39], 261 | whiteBright: [97, 39] 262 | }, 263 | bgColor: { 264 | bgBlack: [40, 49], 265 | bgRed: [41, 49], 266 | bgGreen: [42, 49], 267 | bgYellow: [43, 49], 268 | bgBlue: [44, 49], 269 | bgMagenta: [45, 49], 270 | bgCyan: [46, 49], 271 | bgWhite: [47, 49], 272 | 273 | // Bright color 274 | bgBlackBright: [100, 49], 275 | bgRedBright: [101, 49], 276 | bgGreenBright: [102, 49], 277 | bgYellowBright: [103, 49], 278 | bgBlueBright: [104, 49], 279 | bgMagentaBright: [105, 49], 280 | bgCyanBright: [106, 49], 281 | bgWhiteBright: [107, 49] 282 | } 283 | }; 284 | 285 | // Alias bright black as gray (and grey) 286 | styles.color.gray = styles.color.blackBright; 287 | styles.bgColor.bgGray = styles.bgColor.bgBlackBright; 288 | styles.color.grey = styles.color.blackBright; 289 | styles.bgColor.bgGrey = styles.bgColor.bgBlackBright; 290 | 291 | for (const [groupName, group] of Object.entries(styles)) { 292 | for (const [styleName, style] of Object.entries(group)) { 293 | styles[styleName] = { 294 | open: `\u001B[${style[0]}m`, 295 | close: `\u001B[${style[1]}m` 296 | }; 297 | 298 | group[styleName] = styles[styleName]; 299 | 300 | codes.set(style[0], style[1]); 301 | } 302 | 303 | Object.defineProperty(styles, groupName, { 304 | value: group, 305 | enumerable: false 306 | }); 307 | } 308 | 309 | Object.defineProperty(styles, 'codes', { 310 | value: codes, 311 | enumerable: false 312 | }); 313 | 314 | styles.color.close = '\u001B[39m'; 315 | styles.bgColor.close = '\u001B[49m'; 316 | 317 | setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false)); 318 | setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false)); 319 | setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false)); 320 | setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true)); 321 | setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true)); 322 | setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true)); 323 | 324 | return styles; 325 | } 326 | 327 | // Make the export immutable 328 | Object.defineProperty(module, 'exports', { 329 | enumerable: true, 330 | get: assembleStyles 331 | }); 332 | 333 | /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module))) 334 | 335 | /***/ }), 336 | 337 | /***/ "./node_modules/chalk/source/index.js": 338 | /*!********************************************!*\ 339 | !*** ./node_modules/chalk/source/index.js ***! 340 | \********************************************/ 341 | /*! no static exports found */ 342 | /***/ (function(module, exports, __webpack_require__) { 343 | 344 | "use strict"; 345 | 346 | const ansiStyles = __webpack_require__(/*! ansi-styles */ "./node_modules/ansi-styles/index.js"); 347 | const {stdout: stdoutColor, stderr: stderrColor} = __webpack_require__(/*! supports-color */ "./node_modules/supports-color/browser.js"); 348 | const { 349 | stringReplaceAll, 350 | stringEncaseCRLFWithFirstIndex 351 | } = __webpack_require__(/*! ./util */ "./node_modules/chalk/source/util.js"); 352 | 353 | // `supportsColor.level` → `ansiStyles.color[name]` mapping 354 | const levelMapping = [ 355 | 'ansi', 356 | 'ansi', 357 | 'ansi256', 358 | 'ansi16m' 359 | ]; 360 | 361 | const styles = Object.create(null); 362 | 363 | const applyOptions = (object, options = {}) => { 364 | if (options.level > 3 || options.level < 0) { 365 | throw new Error('The `level` option should be an integer from 0 to 3'); 366 | } 367 | 368 | // Detect level if not set manually 369 | const colorLevel = stdoutColor ? stdoutColor.level : 0; 370 | object.level = options.level === undefined ? colorLevel : options.level; 371 | }; 372 | 373 | class ChalkClass { 374 | constructor(options) { 375 | return chalkFactory(options); 376 | } 377 | } 378 | 379 | const chalkFactory = options => { 380 | const chalk = {}; 381 | applyOptions(chalk, options); 382 | 383 | chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_); 384 | 385 | Object.setPrototypeOf(chalk, Chalk.prototype); 386 | Object.setPrototypeOf(chalk.template, chalk); 387 | 388 | chalk.template.constructor = () => { 389 | throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.'); 390 | }; 391 | 392 | chalk.template.Instance = ChalkClass; 393 | 394 | return chalk.template; 395 | }; 396 | 397 | function Chalk(options) { 398 | return chalkFactory(options); 399 | } 400 | 401 | for (const [styleName, style] of Object.entries(ansiStyles)) { 402 | styles[styleName] = { 403 | get() { 404 | const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty); 405 | Object.defineProperty(this, styleName, {value: builder}); 406 | return builder; 407 | } 408 | }; 409 | } 410 | 411 | styles.visible = { 412 | get() { 413 | const builder = createBuilder(this, this._styler, true); 414 | Object.defineProperty(this, 'visible', {value: builder}); 415 | return builder; 416 | } 417 | }; 418 | 419 | const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256']; 420 | 421 | for (const model of usedModels) { 422 | styles[model] = { 423 | get() { 424 | const {level} = this; 425 | return function (...arguments_) { 426 | const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler); 427 | return createBuilder(this, styler, this._isEmpty); 428 | }; 429 | } 430 | }; 431 | } 432 | 433 | for (const model of usedModels) { 434 | const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); 435 | styles[bgModel] = { 436 | get() { 437 | const {level} = this; 438 | return function (...arguments_) { 439 | const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler); 440 | return createBuilder(this, styler, this._isEmpty); 441 | }; 442 | } 443 | }; 444 | } 445 | 446 | const proto = Object.defineProperties(() => {}, { 447 | ...styles, 448 | level: { 449 | enumerable: true, 450 | get() { 451 | return this._generator.level; 452 | }, 453 | set(level) { 454 | this._generator.level = level; 455 | } 456 | } 457 | }); 458 | 459 | const createStyler = (open, close, parent) => { 460 | let openAll; 461 | let closeAll; 462 | if (parent === undefined) { 463 | openAll = open; 464 | closeAll = close; 465 | } else { 466 | openAll = parent.openAll + open; 467 | closeAll = close + parent.closeAll; 468 | } 469 | 470 | return { 471 | open, 472 | close, 473 | openAll, 474 | closeAll, 475 | parent 476 | }; 477 | }; 478 | 479 | const createBuilder = (self, _styler, _isEmpty) => { 480 | const builder = (...arguments_) => { 481 | // Single argument is hot path, implicit coercion is faster than anything 482 | // eslint-disable-next-line no-implicit-coercion 483 | return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' ')); 484 | }; 485 | 486 | // `__proto__` is used because we must return a function, but there is 487 | // no way to create a function with a different prototype 488 | builder.__proto__ = proto; // eslint-disable-line no-proto 489 | 490 | builder._generator = self; 491 | builder._styler = _styler; 492 | builder._isEmpty = _isEmpty; 493 | 494 | return builder; 495 | }; 496 | 497 | const applyStyle = (self, string) => { 498 | if (self.level <= 0 || !string) { 499 | return self._isEmpty ? '' : string; 500 | } 501 | 502 | let styler = self._styler; 503 | 504 | if (styler === undefined) { 505 | return string; 506 | } 507 | 508 | const {openAll, closeAll} = styler; 509 | if (string.indexOf('\u001B') !== -1) { 510 | while (styler !== undefined) { 511 | // Replace any instances already present with a re-opening code 512 | // otherwise only the part of the string until said closing code 513 | // will be colored, and the rest will simply be 'plain'. 514 | string = stringReplaceAll(string, styler.close, styler.open); 515 | 516 | styler = styler.parent; 517 | } 518 | } 519 | 520 | // We can move both next actions out of loop, because remaining actions in loop won't have 521 | // any/visible effect on parts we add here. Close the styling before a linebreak and reopen 522 | // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92 523 | const lfIndex = string.indexOf('\n'); 524 | if (lfIndex !== -1) { 525 | string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex); 526 | } 527 | 528 | return openAll + string + closeAll; 529 | }; 530 | 531 | let template; 532 | const chalkTag = (chalk, ...strings) => { 533 | const [firstString] = strings; 534 | 535 | if (!Array.isArray(firstString)) { 536 | // If chalk() was called by itself or with a string, 537 | // return the string itself as a string. 538 | return strings.join(' '); 539 | } 540 | 541 | const arguments_ = strings.slice(1); 542 | const parts = [firstString.raw[0]]; 543 | 544 | for (let i = 1; i < firstString.length; i++) { 545 | parts.push( 546 | String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'), 547 | String(firstString.raw[i]) 548 | ); 549 | } 550 | 551 | if (template === undefined) { 552 | template = __webpack_require__(/*! ./templates */ "./node_modules/chalk/source/templates.js"); 553 | } 554 | 555 | return template(chalk, parts.join('')); 556 | }; 557 | 558 | Object.defineProperties(Chalk.prototype, styles); 559 | 560 | const chalk = Chalk(); // eslint-disable-line new-cap 561 | chalk.supportsColor = stdoutColor; 562 | chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap 563 | chalk.stderr.supportsColor = stderrColor; 564 | 565 | // For TypeScript 566 | chalk.Level = { 567 | None: 0, 568 | Basic: 1, 569 | Ansi256: 2, 570 | TrueColor: 3, 571 | 0: 'None', 572 | 1: 'Basic', 573 | 2: 'Ansi256', 574 | 3: 'TrueColor' 575 | }; 576 | 577 | module.exports = chalk; 578 | 579 | 580 | /***/ }), 581 | 582 | /***/ "./node_modules/chalk/source/templates.js": 583 | /*!************************************************!*\ 584 | !*** ./node_modules/chalk/source/templates.js ***! 585 | \************************************************/ 586 | /*! no static exports found */ 587 | /***/ (function(module, exports, __webpack_require__) { 588 | 589 | "use strict"; 590 | 591 | const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; 592 | const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; 593 | const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; 594 | const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi; 595 | 596 | const ESCAPES = new Map([ 597 | ['n', '\n'], 598 | ['r', '\r'], 599 | ['t', '\t'], 600 | ['b', '\b'], 601 | ['f', '\f'], 602 | ['v', '\v'], 603 | ['0', '\0'], 604 | ['\\', '\\'], 605 | ['e', '\u001B'], 606 | ['a', '\u0007'] 607 | ]); 608 | 609 | function unescape(c) { 610 | const u = c[0] === 'u'; 611 | const bracket = c[1] === '{'; 612 | 613 | if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) { 614 | return String.fromCharCode(parseInt(c.slice(1), 16)); 615 | } 616 | 617 | if (u && bracket) { 618 | return String.fromCodePoint(parseInt(c.slice(2, -1), 16)); 619 | } 620 | 621 | return ESCAPES.get(c) || c; 622 | } 623 | 624 | function parseArguments(name, arguments_) { 625 | const results = []; 626 | const chunks = arguments_.trim().split(/\s*,\s*/g); 627 | let matches; 628 | 629 | for (const chunk of chunks) { 630 | const number = Number(chunk); 631 | if (!Number.isNaN(number)) { 632 | results.push(number); 633 | } else if ((matches = chunk.match(STRING_REGEX))) { 634 | results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character)); 635 | } else { 636 | throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); 637 | } 638 | } 639 | 640 | return results; 641 | } 642 | 643 | function parseStyle(style) { 644 | STYLE_REGEX.lastIndex = 0; 645 | 646 | const results = []; 647 | let matches; 648 | 649 | while ((matches = STYLE_REGEX.exec(style)) !== null) { 650 | const name = matches[1]; 651 | 652 | if (matches[2]) { 653 | const args = parseArguments(name, matches[2]); 654 | results.push([name].concat(args)); 655 | } else { 656 | results.push([name]); 657 | } 658 | } 659 | 660 | return results; 661 | } 662 | 663 | function buildStyle(chalk, styles) { 664 | const enabled = {}; 665 | 666 | for (const layer of styles) { 667 | for (const style of layer.styles) { 668 | enabled[style[0]] = layer.inverse ? null : style.slice(1); 669 | } 670 | } 671 | 672 | let current = chalk; 673 | for (const [styleName, styles] of Object.entries(enabled)) { 674 | if (!Array.isArray(styles)) { 675 | continue; 676 | } 677 | 678 | if (!(styleName in current)) { 679 | throw new Error(`Unknown Chalk style: ${styleName}`); 680 | } 681 | 682 | current = styles.length > 0 ? current[styleName](...styles) : current[styleName]; 683 | } 684 | 685 | return current; 686 | } 687 | 688 | module.exports = (chalk, temporary) => { 689 | const styles = []; 690 | const chunks = []; 691 | let chunk = []; 692 | 693 | // eslint-disable-next-line max-params 694 | temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => { 695 | if (escapeCharacter) { 696 | chunk.push(unescape(escapeCharacter)); 697 | } else if (style) { 698 | const string = chunk.join(''); 699 | chunk = []; 700 | chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string)); 701 | styles.push({inverse, styles: parseStyle(style)}); 702 | } else if (close) { 703 | if (styles.length === 0) { 704 | throw new Error('Found extraneous } in Chalk template literal'); 705 | } 706 | 707 | chunks.push(buildStyle(chalk, styles)(chunk.join(''))); 708 | chunk = []; 709 | styles.pop(); 710 | } else { 711 | chunk.push(character); 712 | } 713 | }); 714 | 715 | chunks.push(chunk.join('')); 716 | 717 | if (styles.length > 0) { 718 | const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; 719 | throw new Error(errMsg); 720 | } 721 | 722 | return chunks.join(''); 723 | }; 724 | 725 | 726 | /***/ }), 727 | 728 | /***/ "./node_modules/chalk/source/util.js": 729 | /*!*******************************************!*\ 730 | !*** ./node_modules/chalk/source/util.js ***! 731 | \*******************************************/ 732 | /*! no static exports found */ 733 | /***/ (function(module, exports, __webpack_require__) { 734 | 735 | "use strict"; 736 | 737 | 738 | const stringReplaceAll = (string, substring, replacer) => { 739 | let index = string.indexOf(substring); 740 | if (index === -1) { 741 | return string; 742 | } 743 | 744 | const substringLength = substring.length; 745 | let endIndex = 0; 746 | let returnValue = ''; 747 | do { 748 | returnValue += string.substr(endIndex, index - endIndex) + substring + replacer; 749 | endIndex = index + substringLength; 750 | index = string.indexOf(substring, endIndex); 751 | } while (index !== -1); 752 | 753 | returnValue += string.substr(endIndex); 754 | return returnValue; 755 | }; 756 | 757 | const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => { 758 | let endIndex = 0; 759 | let returnValue = ''; 760 | do { 761 | const gotCR = string[index - 1] === '\r'; 762 | returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix; 763 | endIndex = index + 1; 764 | index = string.indexOf('\n', endIndex); 765 | } while (index !== -1); 766 | 767 | returnValue += string.substr(endIndex); 768 | return returnValue; 769 | }; 770 | 771 | module.exports = { 772 | stringReplaceAll, 773 | stringEncaseCRLFWithFirstIndex 774 | }; 775 | 776 | 777 | /***/ }), 778 | 779 | /***/ "./node_modules/color-convert/conversions.js": 780 | /*!***************************************************!*\ 781 | !*** ./node_modules/color-convert/conversions.js ***! 782 | \***************************************************/ 783 | /*! no static exports found */ 784 | /***/ (function(module, exports, __webpack_require__) { 785 | 786 | /* MIT license */ 787 | /* eslint-disable no-mixed-operators */ 788 | const cssKeywords = __webpack_require__(/*! color-name */ "./node_modules/color-name/index.js"); 789 | 790 | // NOTE: conversions should only return primitive values (i.e. arrays, or 791 | // values that give correct `typeof` results). 792 | // do not use box values types (i.e. Number(), String(), etc.) 793 | 794 | const reverseKeywords = {}; 795 | for (const key of Object.keys(cssKeywords)) { 796 | reverseKeywords[cssKeywords[key]] = key; 797 | } 798 | 799 | const convert = { 800 | rgb: {channels: 3, labels: 'rgb'}, 801 | hsl: {channels: 3, labels: 'hsl'}, 802 | hsv: {channels: 3, labels: 'hsv'}, 803 | hwb: {channels: 3, labels: 'hwb'}, 804 | cmyk: {channels: 4, labels: 'cmyk'}, 805 | xyz: {channels: 3, labels: 'xyz'}, 806 | lab: {channels: 3, labels: 'lab'}, 807 | lch: {channels: 3, labels: 'lch'}, 808 | hex: {channels: 1, labels: ['hex']}, 809 | keyword: {channels: 1, labels: ['keyword']}, 810 | ansi16: {channels: 1, labels: ['ansi16']}, 811 | ansi256: {channels: 1, labels: ['ansi256']}, 812 | hcg: {channels: 3, labels: ['h', 'c', 'g']}, 813 | apple: {channels: 3, labels: ['r16', 'g16', 'b16']}, 814 | gray: {channels: 1, labels: ['gray']} 815 | }; 816 | 817 | module.exports = convert; 818 | 819 | // Hide .channels and .labels properties 820 | for (const model of Object.keys(convert)) { 821 | if (!('channels' in convert[model])) { 822 | throw new Error('missing channels property: ' + model); 823 | } 824 | 825 | if (!('labels' in convert[model])) { 826 | throw new Error('missing channel labels property: ' + model); 827 | } 828 | 829 | if (convert[model].labels.length !== convert[model].channels) { 830 | throw new Error('channel and label counts mismatch: ' + model); 831 | } 832 | 833 | const {channels, labels} = convert[model]; 834 | delete convert[model].channels; 835 | delete convert[model].labels; 836 | Object.defineProperty(convert[model], 'channels', {value: channels}); 837 | Object.defineProperty(convert[model], 'labels', {value: labels}); 838 | } 839 | 840 | convert.rgb.hsl = function (rgb) { 841 | const r = rgb[0] / 255; 842 | const g = rgb[1] / 255; 843 | const b = rgb[2] / 255; 844 | const min = Math.min(r, g, b); 845 | const max = Math.max(r, g, b); 846 | const delta = max - min; 847 | let h; 848 | let s; 849 | 850 | if (max === min) { 851 | h = 0; 852 | } else if (r === max) { 853 | h = (g - b) / delta; 854 | } else if (g === max) { 855 | h = 2 + (b - r) / delta; 856 | } else if (b === max) { 857 | h = 4 + (r - g) / delta; 858 | } 859 | 860 | h = Math.min(h * 60, 360); 861 | 862 | if (h < 0) { 863 | h += 360; 864 | } 865 | 866 | const l = (min + max) / 2; 867 | 868 | if (max === min) { 869 | s = 0; 870 | } else if (l <= 0.5) { 871 | s = delta / (max + min); 872 | } else { 873 | s = delta / (2 - max - min); 874 | } 875 | 876 | return [h, s * 100, l * 100]; 877 | }; 878 | 879 | convert.rgb.hsv = function (rgb) { 880 | let rdif; 881 | let gdif; 882 | let bdif; 883 | let h; 884 | let s; 885 | 886 | const r = rgb[0] / 255; 887 | const g = rgb[1] / 255; 888 | const b = rgb[2] / 255; 889 | const v = Math.max(r, g, b); 890 | const diff = v - Math.min(r, g, b); 891 | const diffc = function (c) { 892 | return (v - c) / 6 / diff + 1 / 2; 893 | }; 894 | 895 | if (diff === 0) { 896 | h = 0; 897 | s = 0; 898 | } else { 899 | s = diff / v; 900 | rdif = diffc(r); 901 | gdif = diffc(g); 902 | bdif = diffc(b); 903 | 904 | if (r === v) { 905 | h = bdif - gdif; 906 | } else if (g === v) { 907 | h = (1 / 3) + rdif - bdif; 908 | } else if (b === v) { 909 | h = (2 / 3) + gdif - rdif; 910 | } 911 | 912 | if (h < 0) { 913 | h += 1; 914 | } else if (h > 1) { 915 | h -= 1; 916 | } 917 | } 918 | 919 | return [ 920 | h * 360, 921 | s * 100, 922 | v * 100 923 | ]; 924 | }; 925 | 926 | convert.rgb.hwb = function (rgb) { 927 | const r = rgb[0]; 928 | const g = rgb[1]; 929 | let b = rgb[2]; 930 | const h = convert.rgb.hsl(rgb)[0]; 931 | const w = 1 / 255 * Math.min(r, Math.min(g, b)); 932 | 933 | b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); 934 | 935 | return [h, w * 100, b * 100]; 936 | }; 937 | 938 | convert.rgb.cmyk = function (rgb) { 939 | const r = rgb[0] / 255; 940 | const g = rgb[1] / 255; 941 | const b = rgb[2] / 255; 942 | 943 | const k = Math.min(1 - r, 1 - g, 1 - b); 944 | const c = (1 - r - k) / (1 - k) || 0; 945 | const m = (1 - g - k) / (1 - k) || 0; 946 | const y = (1 - b - k) / (1 - k) || 0; 947 | 948 | return [c * 100, m * 100, y * 100, k * 100]; 949 | }; 950 | 951 | function comparativeDistance(x, y) { 952 | /* 953 | See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance 954 | */ 955 | return ( 956 | ((x[0] - y[0]) ** 2) + 957 | ((x[1] - y[1]) ** 2) + 958 | ((x[2] - y[2]) ** 2) 959 | ); 960 | } 961 | 962 | convert.rgb.keyword = function (rgb) { 963 | const reversed = reverseKeywords[rgb]; 964 | if (reversed) { 965 | return reversed; 966 | } 967 | 968 | let currentClosestDistance = Infinity; 969 | let currentClosestKeyword; 970 | 971 | for (const keyword of Object.keys(cssKeywords)) { 972 | const value = cssKeywords[keyword]; 973 | 974 | // Compute comparative distance 975 | const distance = comparativeDistance(rgb, value); 976 | 977 | // Check if its less, if so set as closest 978 | if (distance < currentClosestDistance) { 979 | currentClosestDistance = distance; 980 | currentClosestKeyword = keyword; 981 | } 982 | } 983 | 984 | return currentClosestKeyword; 985 | }; 986 | 987 | convert.keyword.rgb = function (keyword) { 988 | return cssKeywords[keyword]; 989 | }; 990 | 991 | convert.rgb.xyz = function (rgb) { 992 | let r = rgb[0] / 255; 993 | let g = rgb[1] / 255; 994 | let b = rgb[2] / 255; 995 | 996 | // Assume sRGB 997 | r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92); 998 | g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92); 999 | b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92); 1000 | 1001 | const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); 1002 | const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); 1003 | const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); 1004 | 1005 | return [x * 100, y * 100, z * 100]; 1006 | }; 1007 | 1008 | convert.rgb.lab = function (rgb) { 1009 | const xyz = convert.rgb.xyz(rgb); 1010 | let x = xyz[0]; 1011 | let y = xyz[1]; 1012 | let z = xyz[2]; 1013 | 1014 | x /= 95.047; 1015 | y /= 100; 1016 | z /= 108.883; 1017 | 1018 | x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116); 1019 | y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116); 1020 | z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116); 1021 | 1022 | const l = (116 * y) - 16; 1023 | const a = 500 * (x - y); 1024 | const b = 200 * (y - z); 1025 | 1026 | return [l, a, b]; 1027 | }; 1028 | 1029 | convert.hsl.rgb = function (hsl) { 1030 | const h = hsl[0] / 360; 1031 | const s = hsl[1] / 100; 1032 | const l = hsl[2] / 100; 1033 | let t2; 1034 | let t3; 1035 | let val; 1036 | 1037 | if (s === 0) { 1038 | val = l * 255; 1039 | return [val, val, val]; 1040 | } 1041 | 1042 | if (l < 0.5) { 1043 | t2 = l * (1 + s); 1044 | } else { 1045 | t2 = l + s - l * s; 1046 | } 1047 | 1048 | const t1 = 2 * l - t2; 1049 | 1050 | const rgb = [0, 0, 0]; 1051 | for (let i = 0; i < 3; i++) { 1052 | t3 = h + 1 / 3 * -(i - 1); 1053 | if (t3 < 0) { 1054 | t3++; 1055 | } 1056 | 1057 | if (t3 > 1) { 1058 | t3--; 1059 | } 1060 | 1061 | if (6 * t3 < 1) { 1062 | val = t1 + (t2 - t1) * 6 * t3; 1063 | } else if (2 * t3 < 1) { 1064 | val = t2; 1065 | } else if (3 * t3 < 2) { 1066 | val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; 1067 | } else { 1068 | val = t1; 1069 | } 1070 | 1071 | rgb[i] = val * 255; 1072 | } 1073 | 1074 | return rgb; 1075 | }; 1076 | 1077 | convert.hsl.hsv = function (hsl) { 1078 | const h = hsl[0]; 1079 | let s = hsl[1] / 100; 1080 | let l = hsl[2] / 100; 1081 | let smin = s; 1082 | const lmin = Math.max(l, 0.01); 1083 | 1084 | l *= 2; 1085 | s *= (l <= 1) ? l : 2 - l; 1086 | smin *= lmin <= 1 ? lmin : 2 - lmin; 1087 | const v = (l + s) / 2; 1088 | const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s); 1089 | 1090 | return [h, sv * 100, v * 100]; 1091 | }; 1092 | 1093 | convert.hsv.rgb = function (hsv) { 1094 | const h = hsv[0] / 60; 1095 | const s = hsv[1] / 100; 1096 | let v = hsv[2] / 100; 1097 | const hi = Math.floor(h) % 6; 1098 | 1099 | const f = h - Math.floor(h); 1100 | const p = 255 * v * (1 - s); 1101 | const q = 255 * v * (1 - (s * f)); 1102 | const t = 255 * v * (1 - (s * (1 - f))); 1103 | v *= 255; 1104 | 1105 | switch (hi) { 1106 | case 0: 1107 | return [v, t, p]; 1108 | case 1: 1109 | return [q, v, p]; 1110 | case 2: 1111 | return [p, v, t]; 1112 | case 3: 1113 | return [p, q, v]; 1114 | case 4: 1115 | return [t, p, v]; 1116 | case 5: 1117 | return [v, p, q]; 1118 | } 1119 | }; 1120 | 1121 | convert.hsv.hsl = function (hsv) { 1122 | const h = hsv[0]; 1123 | const s = hsv[1] / 100; 1124 | const v = hsv[2] / 100; 1125 | const vmin = Math.max(v, 0.01); 1126 | let sl; 1127 | let l; 1128 | 1129 | l = (2 - s) * v; 1130 | const lmin = (2 - s) * vmin; 1131 | sl = s * vmin; 1132 | sl /= (lmin <= 1) ? lmin : 2 - lmin; 1133 | sl = sl || 0; 1134 | l /= 2; 1135 | 1136 | return [h, sl * 100, l * 100]; 1137 | }; 1138 | 1139 | // http://dev.w3.org/csswg/css-color/#hwb-to-rgb 1140 | convert.hwb.rgb = function (hwb) { 1141 | const h = hwb[0] / 360; 1142 | let wh = hwb[1] / 100; 1143 | let bl = hwb[2] / 100; 1144 | const ratio = wh + bl; 1145 | let f; 1146 | 1147 | // Wh + bl cant be > 1 1148 | if (ratio > 1) { 1149 | wh /= ratio; 1150 | bl /= ratio; 1151 | } 1152 | 1153 | const i = Math.floor(6 * h); 1154 | const v = 1 - bl; 1155 | f = 6 * h - i; 1156 | 1157 | if ((i & 0x01) !== 0) { 1158 | f = 1 - f; 1159 | } 1160 | 1161 | const n = wh + f * (v - wh); // Linear interpolation 1162 | 1163 | let r; 1164 | let g; 1165 | let b; 1166 | /* eslint-disable max-statements-per-line,no-multi-spaces */ 1167 | switch (i) { 1168 | default: 1169 | case 6: 1170 | case 0: r = v; g = n; b = wh; break; 1171 | case 1: r = n; g = v; b = wh; break; 1172 | case 2: r = wh; g = v; b = n; break; 1173 | case 3: r = wh; g = n; b = v; break; 1174 | case 4: r = n; g = wh; b = v; break; 1175 | case 5: r = v; g = wh; b = n; break; 1176 | } 1177 | /* eslint-enable max-statements-per-line,no-multi-spaces */ 1178 | 1179 | return [r * 255, g * 255, b * 255]; 1180 | }; 1181 | 1182 | convert.cmyk.rgb = function (cmyk) { 1183 | const c = cmyk[0] / 100; 1184 | const m = cmyk[1] / 100; 1185 | const y = cmyk[2] / 100; 1186 | const k = cmyk[3] / 100; 1187 | 1188 | const r = 1 - Math.min(1, c * (1 - k) + k); 1189 | const g = 1 - Math.min(1, m * (1 - k) + k); 1190 | const b = 1 - Math.min(1, y * (1 - k) + k); 1191 | 1192 | return [r * 255, g * 255, b * 255]; 1193 | }; 1194 | 1195 | convert.xyz.rgb = function (xyz) { 1196 | const x = xyz[0] / 100; 1197 | const y = xyz[1] / 100; 1198 | const z = xyz[2] / 100; 1199 | let r; 1200 | let g; 1201 | let b; 1202 | 1203 | r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); 1204 | g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); 1205 | b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); 1206 | 1207 | // Assume sRGB 1208 | r = r > 0.0031308 1209 | ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055) 1210 | : r * 12.92; 1211 | 1212 | g = g > 0.0031308 1213 | ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055) 1214 | : g * 12.92; 1215 | 1216 | b = b > 0.0031308 1217 | ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055) 1218 | : b * 12.92; 1219 | 1220 | r = Math.min(Math.max(0, r), 1); 1221 | g = Math.min(Math.max(0, g), 1); 1222 | b = Math.min(Math.max(0, b), 1); 1223 | 1224 | return [r * 255, g * 255, b * 255]; 1225 | }; 1226 | 1227 | convert.xyz.lab = function (xyz) { 1228 | let x = xyz[0]; 1229 | let y = xyz[1]; 1230 | let z = xyz[2]; 1231 | 1232 | x /= 95.047; 1233 | y /= 100; 1234 | z /= 108.883; 1235 | 1236 | x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116); 1237 | y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116); 1238 | z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116); 1239 | 1240 | const l = (116 * y) - 16; 1241 | const a = 500 * (x - y); 1242 | const b = 200 * (y - z); 1243 | 1244 | return [l, a, b]; 1245 | }; 1246 | 1247 | convert.lab.xyz = function (lab) { 1248 | const l = lab[0]; 1249 | const a = lab[1]; 1250 | const b = lab[2]; 1251 | let x; 1252 | let y; 1253 | let z; 1254 | 1255 | y = (l + 16) / 116; 1256 | x = a / 500 + y; 1257 | z = y - b / 200; 1258 | 1259 | const y2 = y ** 3; 1260 | const x2 = x ** 3; 1261 | const z2 = z ** 3; 1262 | y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; 1263 | x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; 1264 | z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; 1265 | 1266 | x *= 95.047; 1267 | y *= 100; 1268 | z *= 108.883; 1269 | 1270 | return [x, y, z]; 1271 | }; 1272 | 1273 | convert.lab.lch = function (lab) { 1274 | const l = lab[0]; 1275 | const a = lab[1]; 1276 | const b = lab[2]; 1277 | let h; 1278 | 1279 | const hr = Math.atan2(b, a); 1280 | h = hr * 360 / 2 / Math.PI; 1281 | 1282 | if (h < 0) { 1283 | h += 360; 1284 | } 1285 | 1286 | const c = Math.sqrt(a * a + b * b); 1287 | 1288 | return [l, c, h]; 1289 | }; 1290 | 1291 | convert.lch.lab = function (lch) { 1292 | const l = lch[0]; 1293 | const c = lch[1]; 1294 | const h = lch[2]; 1295 | 1296 | const hr = h / 360 * 2 * Math.PI; 1297 | const a = c * Math.cos(hr); 1298 | const b = c * Math.sin(hr); 1299 | 1300 | return [l, a, b]; 1301 | }; 1302 | 1303 | convert.rgb.ansi16 = function (args, saturation = null) { 1304 | const [r, g, b] = args; 1305 | let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization 1306 | 1307 | value = Math.round(value / 50); 1308 | 1309 | if (value === 0) { 1310 | return 30; 1311 | } 1312 | 1313 | let ansi = 30 1314 | + ((Math.round(b / 255) << 2) 1315 | | (Math.round(g / 255) << 1) 1316 | | Math.round(r / 255)); 1317 | 1318 | if (value === 2) { 1319 | ansi += 60; 1320 | } 1321 | 1322 | return ansi; 1323 | }; 1324 | 1325 | convert.hsv.ansi16 = function (args) { 1326 | // Optimization here; we already know the value and don't need to get 1327 | // it converted for us. 1328 | return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]); 1329 | }; 1330 | 1331 | convert.rgb.ansi256 = function (args) { 1332 | const r = args[0]; 1333 | const g = args[1]; 1334 | const b = args[2]; 1335 | 1336 | // We use the extended greyscale palette here, with the exception of 1337 | // black and white. normal palette only has 4 greyscale shades. 1338 | if (r === g && g === b) { 1339 | if (r < 8) { 1340 | return 16; 1341 | } 1342 | 1343 | if (r > 248) { 1344 | return 231; 1345 | } 1346 | 1347 | return Math.round(((r - 8) / 247) * 24) + 232; 1348 | } 1349 | 1350 | const ansi = 16 1351 | + (36 * Math.round(r / 255 * 5)) 1352 | + (6 * Math.round(g / 255 * 5)) 1353 | + Math.round(b / 255 * 5); 1354 | 1355 | return ansi; 1356 | }; 1357 | 1358 | convert.ansi16.rgb = function (args) { 1359 | let color = args % 10; 1360 | 1361 | // Handle greyscale 1362 | if (color === 0 || color === 7) { 1363 | if (args > 50) { 1364 | color += 3.5; 1365 | } 1366 | 1367 | color = color / 10.5 * 255; 1368 | 1369 | return [color, color, color]; 1370 | } 1371 | 1372 | const mult = (~~(args > 50) + 1) * 0.5; 1373 | const r = ((color & 1) * mult) * 255; 1374 | const g = (((color >> 1) & 1) * mult) * 255; 1375 | const b = (((color >> 2) & 1) * mult) * 255; 1376 | 1377 | return [r, g, b]; 1378 | }; 1379 | 1380 | convert.ansi256.rgb = function (args) { 1381 | // Handle greyscale 1382 | if (args >= 232) { 1383 | const c = (args - 232) * 10 + 8; 1384 | return [c, c, c]; 1385 | } 1386 | 1387 | args -= 16; 1388 | 1389 | let rem; 1390 | const r = Math.floor(args / 36) / 5 * 255; 1391 | const g = Math.floor((rem = args % 36) / 6) / 5 * 255; 1392 | const b = (rem % 6) / 5 * 255; 1393 | 1394 | return [r, g, b]; 1395 | }; 1396 | 1397 | convert.rgb.hex = function (args) { 1398 | const integer = ((Math.round(args[0]) & 0xFF) << 16) 1399 | + ((Math.round(args[1]) & 0xFF) << 8) 1400 | + (Math.round(args[2]) & 0xFF); 1401 | 1402 | const string = integer.toString(16).toUpperCase(); 1403 | return '000000'.substring(string.length) + string; 1404 | }; 1405 | 1406 | convert.hex.rgb = function (args) { 1407 | const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); 1408 | if (!match) { 1409 | return [0, 0, 0]; 1410 | } 1411 | 1412 | let colorString = match[0]; 1413 | 1414 | if (match[0].length === 3) { 1415 | colorString = colorString.split('').map(char => { 1416 | return char + char; 1417 | }).join(''); 1418 | } 1419 | 1420 | const integer = parseInt(colorString, 16); 1421 | const r = (integer >> 16) & 0xFF; 1422 | const g = (integer >> 8) & 0xFF; 1423 | const b = integer & 0xFF; 1424 | 1425 | return [r, g, b]; 1426 | }; 1427 | 1428 | convert.rgb.hcg = function (rgb) { 1429 | const r = rgb[0] / 255; 1430 | const g = rgb[1] / 255; 1431 | const b = rgb[2] / 255; 1432 | const max = Math.max(Math.max(r, g), b); 1433 | const min = Math.min(Math.min(r, g), b); 1434 | const chroma = (max - min); 1435 | let grayscale; 1436 | let hue; 1437 | 1438 | if (chroma < 1) { 1439 | grayscale = min / (1 - chroma); 1440 | } else { 1441 | grayscale = 0; 1442 | } 1443 | 1444 | if (chroma <= 0) { 1445 | hue = 0; 1446 | } else 1447 | if (max === r) { 1448 | hue = ((g - b) / chroma) % 6; 1449 | } else 1450 | if (max === g) { 1451 | hue = 2 + (b - r) / chroma; 1452 | } else { 1453 | hue = 4 + (r - g) / chroma; 1454 | } 1455 | 1456 | hue /= 6; 1457 | hue %= 1; 1458 | 1459 | return [hue * 360, chroma * 100, grayscale * 100]; 1460 | }; 1461 | 1462 | convert.hsl.hcg = function (hsl) { 1463 | const s = hsl[1] / 100; 1464 | const l = hsl[2] / 100; 1465 | 1466 | const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l)); 1467 | 1468 | let f = 0; 1469 | if (c < 1.0) { 1470 | f = (l - 0.5 * c) / (1.0 - c); 1471 | } 1472 | 1473 | return [hsl[0], c * 100, f * 100]; 1474 | }; 1475 | 1476 | convert.hsv.hcg = function (hsv) { 1477 | const s = hsv[1] / 100; 1478 | const v = hsv[2] / 100; 1479 | 1480 | const c = s * v; 1481 | let f = 0; 1482 | 1483 | if (c < 1.0) { 1484 | f = (v - c) / (1 - c); 1485 | } 1486 | 1487 | return [hsv[0], c * 100, f * 100]; 1488 | }; 1489 | 1490 | convert.hcg.rgb = function (hcg) { 1491 | const h = hcg[0] / 360; 1492 | const c = hcg[1] / 100; 1493 | const g = hcg[2] / 100; 1494 | 1495 | if (c === 0.0) { 1496 | return [g * 255, g * 255, g * 255]; 1497 | } 1498 | 1499 | const pure = [0, 0, 0]; 1500 | const hi = (h % 1) * 6; 1501 | const v = hi % 1; 1502 | const w = 1 - v; 1503 | let mg = 0; 1504 | 1505 | /* eslint-disable max-statements-per-line */ 1506 | switch (Math.floor(hi)) { 1507 | case 0: 1508 | pure[0] = 1; pure[1] = v; pure[2] = 0; break; 1509 | case 1: 1510 | pure[0] = w; pure[1] = 1; pure[2] = 0; break; 1511 | case 2: 1512 | pure[0] = 0; pure[1] = 1; pure[2] = v; break; 1513 | case 3: 1514 | pure[0] = 0; pure[1] = w; pure[2] = 1; break; 1515 | case 4: 1516 | pure[0] = v; pure[1] = 0; pure[2] = 1; break; 1517 | default: 1518 | pure[0] = 1; pure[1] = 0; pure[2] = w; 1519 | } 1520 | /* eslint-enable max-statements-per-line */ 1521 | 1522 | mg = (1.0 - c) * g; 1523 | 1524 | return [ 1525 | (c * pure[0] + mg) * 255, 1526 | (c * pure[1] + mg) * 255, 1527 | (c * pure[2] + mg) * 255 1528 | ]; 1529 | }; 1530 | 1531 | convert.hcg.hsv = function (hcg) { 1532 | const c = hcg[1] / 100; 1533 | const g = hcg[2] / 100; 1534 | 1535 | const v = c + g * (1.0 - c); 1536 | let f = 0; 1537 | 1538 | if (v > 0.0) { 1539 | f = c / v; 1540 | } 1541 | 1542 | return [hcg[0], f * 100, v * 100]; 1543 | }; 1544 | 1545 | convert.hcg.hsl = function (hcg) { 1546 | const c = hcg[1] / 100; 1547 | const g = hcg[2] / 100; 1548 | 1549 | const l = g * (1.0 - c) + 0.5 * c; 1550 | let s = 0; 1551 | 1552 | if (l > 0.0 && l < 0.5) { 1553 | s = c / (2 * l); 1554 | } else 1555 | if (l >= 0.5 && l < 1.0) { 1556 | s = c / (2 * (1 - l)); 1557 | } 1558 | 1559 | return [hcg[0], s * 100, l * 100]; 1560 | }; 1561 | 1562 | convert.hcg.hwb = function (hcg) { 1563 | const c = hcg[1] / 100; 1564 | const g = hcg[2] / 100; 1565 | const v = c + g * (1.0 - c); 1566 | return [hcg[0], (v - c) * 100, (1 - v) * 100]; 1567 | }; 1568 | 1569 | convert.hwb.hcg = function (hwb) { 1570 | const w = hwb[1] / 100; 1571 | const b = hwb[2] / 100; 1572 | const v = 1 - b; 1573 | const c = v - w; 1574 | let g = 0; 1575 | 1576 | if (c < 1) { 1577 | g = (v - c) / (1 - c); 1578 | } 1579 | 1580 | return [hwb[0], c * 100, g * 100]; 1581 | }; 1582 | 1583 | convert.apple.rgb = function (apple) { 1584 | return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255]; 1585 | }; 1586 | 1587 | convert.rgb.apple = function (rgb) { 1588 | return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535]; 1589 | }; 1590 | 1591 | convert.gray.rgb = function (args) { 1592 | return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; 1593 | }; 1594 | 1595 | convert.gray.hsl = function (args) { 1596 | return [0, 0, args[0]]; 1597 | }; 1598 | 1599 | convert.gray.hsv = convert.gray.hsl; 1600 | 1601 | convert.gray.hwb = function (gray) { 1602 | return [0, 100, gray[0]]; 1603 | }; 1604 | 1605 | convert.gray.cmyk = function (gray) { 1606 | return [0, 0, 0, gray[0]]; 1607 | }; 1608 | 1609 | convert.gray.lab = function (gray) { 1610 | return [gray[0], 0, 0]; 1611 | }; 1612 | 1613 | convert.gray.hex = function (gray) { 1614 | const val = Math.round(gray[0] / 100 * 255) & 0xFF; 1615 | const integer = (val << 16) + (val << 8) + val; 1616 | 1617 | const string = integer.toString(16).toUpperCase(); 1618 | return '000000'.substring(string.length) + string; 1619 | }; 1620 | 1621 | convert.rgb.gray = function (rgb) { 1622 | const val = (rgb[0] + rgb[1] + rgb[2]) / 3; 1623 | return [val / 255 * 100]; 1624 | }; 1625 | 1626 | 1627 | /***/ }), 1628 | 1629 | /***/ "./node_modules/color-convert/index.js": 1630 | /*!*********************************************!*\ 1631 | !*** ./node_modules/color-convert/index.js ***! 1632 | \*********************************************/ 1633 | /*! no static exports found */ 1634 | /***/ (function(module, exports, __webpack_require__) { 1635 | 1636 | const conversions = __webpack_require__(/*! ./conversions */ "./node_modules/color-convert/conversions.js"); 1637 | const route = __webpack_require__(/*! ./route */ "./node_modules/color-convert/route.js"); 1638 | 1639 | const convert = {}; 1640 | 1641 | const models = Object.keys(conversions); 1642 | 1643 | function wrapRaw(fn) { 1644 | const wrappedFn = function (...args) { 1645 | const arg0 = args[0]; 1646 | if (arg0 === undefined || arg0 === null) { 1647 | return arg0; 1648 | } 1649 | 1650 | if (arg0.length > 1) { 1651 | args = arg0; 1652 | } 1653 | 1654 | return fn(args); 1655 | }; 1656 | 1657 | // Preserve .conversion property if there is one 1658 | if ('conversion' in fn) { 1659 | wrappedFn.conversion = fn.conversion; 1660 | } 1661 | 1662 | return wrappedFn; 1663 | } 1664 | 1665 | function wrapRounded(fn) { 1666 | const wrappedFn = function (...args) { 1667 | const arg0 = args[0]; 1668 | 1669 | if (arg0 === undefined || arg0 === null) { 1670 | return arg0; 1671 | } 1672 | 1673 | if (arg0.length > 1) { 1674 | args = arg0; 1675 | } 1676 | 1677 | const result = fn(args); 1678 | 1679 | // We're assuming the result is an array here. 1680 | // see notice in conversions.js; don't use box types 1681 | // in conversion functions. 1682 | if (typeof result === 'object') { 1683 | for (let len = result.length, i = 0; i < len; i++) { 1684 | result[i] = Math.round(result[i]); 1685 | } 1686 | } 1687 | 1688 | return result; 1689 | }; 1690 | 1691 | // Preserve .conversion property if there is one 1692 | if ('conversion' in fn) { 1693 | wrappedFn.conversion = fn.conversion; 1694 | } 1695 | 1696 | return wrappedFn; 1697 | } 1698 | 1699 | models.forEach(fromModel => { 1700 | convert[fromModel] = {}; 1701 | 1702 | Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels}); 1703 | Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels}); 1704 | 1705 | const routes = route(fromModel); 1706 | const routeModels = Object.keys(routes); 1707 | 1708 | routeModels.forEach(toModel => { 1709 | const fn = routes[toModel]; 1710 | 1711 | convert[fromModel][toModel] = wrapRounded(fn); 1712 | convert[fromModel][toModel].raw = wrapRaw(fn); 1713 | }); 1714 | }); 1715 | 1716 | module.exports = convert; 1717 | 1718 | 1719 | /***/ }), 1720 | 1721 | /***/ "./node_modules/color-convert/route.js": 1722 | /*!*********************************************!*\ 1723 | !*** ./node_modules/color-convert/route.js ***! 1724 | \*********************************************/ 1725 | /*! no static exports found */ 1726 | /***/ (function(module, exports, __webpack_require__) { 1727 | 1728 | const conversions = __webpack_require__(/*! ./conversions */ "./node_modules/color-convert/conversions.js"); 1729 | 1730 | /* 1731 | This function routes a model to all other models. 1732 | 1733 | all functions that are routed have a property `.conversion` attached 1734 | to the returned synthetic function. This property is an array 1735 | of strings, each with the steps in between the 'from' and 'to' 1736 | color models (inclusive). 1737 | 1738 | conversions that are not possible simply are not included. 1739 | */ 1740 | 1741 | function buildGraph() { 1742 | const graph = {}; 1743 | // https://jsperf.com/object-keys-vs-for-in-with-closure/3 1744 | const models = Object.keys(conversions); 1745 | 1746 | for (let len = models.length, i = 0; i < len; i++) { 1747 | graph[models[i]] = { 1748 | // http://jsperf.com/1-vs-infinity 1749 | // micro-opt, but this is simple. 1750 | distance: -1, 1751 | parent: null 1752 | }; 1753 | } 1754 | 1755 | return graph; 1756 | } 1757 | 1758 | // https://en.wikipedia.org/wiki/Breadth-first_search 1759 | function deriveBFS(fromModel) { 1760 | const graph = buildGraph(); 1761 | const queue = [fromModel]; // Unshift -> queue -> pop 1762 | 1763 | graph[fromModel].distance = 0; 1764 | 1765 | while (queue.length) { 1766 | const current = queue.pop(); 1767 | const adjacents = Object.keys(conversions[current]); 1768 | 1769 | for (let len = adjacents.length, i = 0; i < len; i++) { 1770 | const adjacent = adjacents[i]; 1771 | const node = graph[adjacent]; 1772 | 1773 | if (node.distance === -1) { 1774 | node.distance = graph[current].distance + 1; 1775 | node.parent = current; 1776 | queue.unshift(adjacent); 1777 | } 1778 | } 1779 | } 1780 | 1781 | return graph; 1782 | } 1783 | 1784 | function link(from, to) { 1785 | return function (args) { 1786 | return to(from(args)); 1787 | }; 1788 | } 1789 | 1790 | function wrapConversion(toModel, graph) { 1791 | const path = [graph[toModel].parent, toModel]; 1792 | let fn = conversions[graph[toModel].parent][toModel]; 1793 | 1794 | let cur = graph[toModel].parent; 1795 | while (graph[cur].parent) { 1796 | path.unshift(graph[cur].parent); 1797 | fn = link(conversions[graph[cur].parent][cur], fn); 1798 | cur = graph[cur].parent; 1799 | } 1800 | 1801 | fn.conversion = path; 1802 | return fn; 1803 | } 1804 | 1805 | module.exports = function (fromModel) { 1806 | const graph = deriveBFS(fromModel); 1807 | const conversion = {}; 1808 | 1809 | const models = Object.keys(graph); 1810 | for (let len = models.length, i = 0; i < len; i++) { 1811 | const toModel = models[i]; 1812 | const node = graph[toModel]; 1813 | 1814 | if (node.parent === null) { 1815 | // No possible conversion, or this node is the source model. 1816 | continue; 1817 | } 1818 | 1819 | conversion[toModel] = wrapConversion(toModel, graph); 1820 | } 1821 | 1822 | return conversion; 1823 | }; 1824 | 1825 | 1826 | 1827 | /***/ }), 1828 | 1829 | /***/ "./node_modules/color-name/index.js": 1830 | /*!******************************************!*\ 1831 | !*** ./node_modules/color-name/index.js ***! 1832 | \******************************************/ 1833 | /*! no static exports found */ 1834 | /***/ (function(module, exports, __webpack_require__) { 1835 | 1836 | "use strict"; 1837 | 1838 | 1839 | module.exports = { 1840 | "aliceblue": [240, 248, 255], 1841 | "antiquewhite": [250, 235, 215], 1842 | "aqua": [0, 255, 255], 1843 | "aquamarine": [127, 255, 212], 1844 | "azure": [240, 255, 255], 1845 | "beige": [245, 245, 220], 1846 | "bisque": [255, 228, 196], 1847 | "black": [0, 0, 0], 1848 | "blanchedalmond": [255, 235, 205], 1849 | "blue": [0, 0, 255], 1850 | "blueviolet": [138, 43, 226], 1851 | "brown": [165, 42, 42], 1852 | "burlywood": [222, 184, 135], 1853 | "cadetblue": [95, 158, 160], 1854 | "chartreuse": [127, 255, 0], 1855 | "chocolate": [210, 105, 30], 1856 | "coral": [255, 127, 80], 1857 | "cornflowerblue": [100, 149, 237], 1858 | "cornsilk": [255, 248, 220], 1859 | "crimson": [220, 20, 60], 1860 | "cyan": [0, 255, 255], 1861 | "darkblue": [0, 0, 139], 1862 | "darkcyan": [0, 139, 139], 1863 | "darkgoldenrod": [184, 134, 11], 1864 | "darkgray": [169, 169, 169], 1865 | "darkgreen": [0, 100, 0], 1866 | "darkgrey": [169, 169, 169], 1867 | "darkkhaki": [189, 183, 107], 1868 | "darkmagenta": [139, 0, 139], 1869 | "darkolivegreen": [85, 107, 47], 1870 | "darkorange": [255, 140, 0], 1871 | "darkorchid": [153, 50, 204], 1872 | "darkred": [139, 0, 0], 1873 | "darksalmon": [233, 150, 122], 1874 | "darkseagreen": [143, 188, 143], 1875 | "darkslateblue": [72, 61, 139], 1876 | "darkslategray": [47, 79, 79], 1877 | "darkslategrey": [47, 79, 79], 1878 | "darkturquoise": [0, 206, 209], 1879 | "darkviolet": [148, 0, 211], 1880 | "deeppink": [255, 20, 147], 1881 | "deepskyblue": [0, 191, 255], 1882 | "dimgray": [105, 105, 105], 1883 | "dimgrey": [105, 105, 105], 1884 | "dodgerblue": [30, 144, 255], 1885 | "firebrick": [178, 34, 34], 1886 | "floralwhite": [255, 250, 240], 1887 | "forestgreen": [34, 139, 34], 1888 | "fuchsia": [255, 0, 255], 1889 | "gainsboro": [220, 220, 220], 1890 | "ghostwhite": [248, 248, 255], 1891 | "gold": [255, 215, 0], 1892 | "goldenrod": [218, 165, 32], 1893 | "gray": [128, 128, 128], 1894 | "green": [0, 128, 0], 1895 | "greenyellow": [173, 255, 47], 1896 | "grey": [128, 128, 128], 1897 | "honeydew": [240, 255, 240], 1898 | "hotpink": [255, 105, 180], 1899 | "indianred": [205, 92, 92], 1900 | "indigo": [75, 0, 130], 1901 | "ivory": [255, 255, 240], 1902 | "khaki": [240, 230, 140], 1903 | "lavender": [230, 230, 250], 1904 | "lavenderblush": [255, 240, 245], 1905 | "lawngreen": [124, 252, 0], 1906 | "lemonchiffon": [255, 250, 205], 1907 | "lightblue": [173, 216, 230], 1908 | "lightcoral": [240, 128, 128], 1909 | "lightcyan": [224, 255, 255], 1910 | "lightgoldenrodyellow": [250, 250, 210], 1911 | "lightgray": [211, 211, 211], 1912 | "lightgreen": [144, 238, 144], 1913 | "lightgrey": [211, 211, 211], 1914 | "lightpink": [255, 182, 193], 1915 | "lightsalmon": [255, 160, 122], 1916 | "lightseagreen": [32, 178, 170], 1917 | "lightskyblue": [135, 206, 250], 1918 | "lightslategray": [119, 136, 153], 1919 | "lightslategrey": [119, 136, 153], 1920 | "lightsteelblue": [176, 196, 222], 1921 | "lightyellow": [255, 255, 224], 1922 | "lime": [0, 255, 0], 1923 | "limegreen": [50, 205, 50], 1924 | "linen": [250, 240, 230], 1925 | "magenta": [255, 0, 255], 1926 | "maroon": [128, 0, 0], 1927 | "mediumaquamarine": [102, 205, 170], 1928 | "mediumblue": [0, 0, 205], 1929 | "mediumorchid": [186, 85, 211], 1930 | "mediumpurple": [147, 112, 219], 1931 | "mediumseagreen": [60, 179, 113], 1932 | "mediumslateblue": [123, 104, 238], 1933 | "mediumspringgreen": [0, 250, 154], 1934 | "mediumturquoise": [72, 209, 204], 1935 | "mediumvioletred": [199, 21, 133], 1936 | "midnightblue": [25, 25, 112], 1937 | "mintcream": [245, 255, 250], 1938 | "mistyrose": [255, 228, 225], 1939 | "moccasin": [255, 228, 181], 1940 | "navajowhite": [255, 222, 173], 1941 | "navy": [0, 0, 128], 1942 | "oldlace": [253, 245, 230], 1943 | "olive": [128, 128, 0], 1944 | "olivedrab": [107, 142, 35], 1945 | "orange": [255, 165, 0], 1946 | "orangered": [255, 69, 0], 1947 | "orchid": [218, 112, 214], 1948 | "palegoldenrod": [238, 232, 170], 1949 | "palegreen": [152, 251, 152], 1950 | "paleturquoise": [175, 238, 238], 1951 | "palevioletred": [219, 112, 147], 1952 | "papayawhip": [255, 239, 213], 1953 | "peachpuff": [255, 218, 185], 1954 | "peru": [205, 133, 63], 1955 | "pink": [255, 192, 203], 1956 | "plum": [221, 160, 221], 1957 | "powderblue": [176, 224, 230], 1958 | "purple": [128, 0, 128], 1959 | "rebeccapurple": [102, 51, 153], 1960 | "red": [255, 0, 0], 1961 | "rosybrown": [188, 143, 143], 1962 | "royalblue": [65, 105, 225], 1963 | "saddlebrown": [139, 69, 19], 1964 | "salmon": [250, 128, 114], 1965 | "sandybrown": [244, 164, 96], 1966 | "seagreen": [46, 139, 87], 1967 | "seashell": [255, 245, 238], 1968 | "sienna": [160, 82, 45], 1969 | "silver": [192, 192, 192], 1970 | "skyblue": [135, 206, 235], 1971 | "slateblue": [106, 90, 205], 1972 | "slategray": [112, 128, 144], 1973 | "slategrey": [112, 128, 144], 1974 | "snow": [255, 250, 250], 1975 | "springgreen": [0, 255, 127], 1976 | "steelblue": [70, 130, 180], 1977 | "tan": [210, 180, 140], 1978 | "teal": [0, 128, 128], 1979 | "thistle": [216, 191, 216], 1980 | "tomato": [255, 99, 71], 1981 | "turquoise": [64, 224, 208], 1982 | "violet": [238, 130, 238], 1983 | "wheat": [245, 222, 179], 1984 | "white": [255, 255, 255], 1985 | "whitesmoke": [245, 245, 245], 1986 | "yellow": [255, 255, 0], 1987 | "yellowgreen": [154, 205, 50] 1988 | }; 1989 | 1990 | 1991 | /***/ }), 1992 | 1993 | /***/ "./node_modules/supports-color/browser.js": 1994 | /*!************************************************!*\ 1995 | !*** ./node_modules/supports-color/browser.js ***! 1996 | \************************************************/ 1997 | /*! no static exports found */ 1998 | /***/ (function(module, exports, __webpack_require__) { 1999 | 2000 | "use strict"; 2001 | 2002 | module.exports = { 2003 | stdout: false, 2004 | stderr: false 2005 | }; 2006 | 2007 | 2008 | /***/ }), 2009 | 2010 | /***/ "./node_modules/webpack/buildin/module.js": 2011 | /*!***********************************!*\ 2012 | !*** (webpack)/buildin/module.js ***! 2013 | \***********************************/ 2014 | /*! no static exports found */ 2015 | /***/ (function(module, exports) { 2016 | 2017 | module.exports = function(module) { 2018 | if (!module.webpackPolyfill) { 2019 | module.deprecate = function() {}; 2020 | module.paths = []; 2021 | // module.parent = undefined by default 2022 | if (!module.children) module.children = []; 2023 | Object.defineProperty(module, "loaded", { 2024 | enumerable: true, 2025 | get: function() { 2026 | return module.l; 2027 | } 2028 | }); 2029 | Object.defineProperty(module, "id", { 2030 | enumerable: true, 2031 | get: function() { 2032 | return module.i; 2033 | } 2034 | }); 2035 | module.webpackPolyfill = 1; 2036 | } 2037 | return module; 2038 | }; 2039 | 2040 | 2041 | /***/ }) 2042 | 2043 | /******/ }); 2044 | //# sourceMappingURL=d.js.map -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/mixed-dep/dir/d.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./__tests__/fixtures/should-not-omit/shared/colorful.js","webpack:///./__tests__/fixtures/should-not-omit/shared/mixed.js","webpack:///./__tests__/fixtures/should-not-omit/shared/one.css?aa36","webpack:///./__tests__/fixtures/should-not-omit/shared/one.js","webpack:///./__tests__/fixtures/should-not-omit/shared/styles.js","webpack:///./__tests__/fixtures/should-not-omit/shared/two.css?a812","webpack:///./node_modules/ansi-styles/index.js","webpack:///./node_modules/chalk/source/index.js","webpack:///./node_modules/chalk/source/templates.js","webpack:///./node_modules/chalk/source/util.js","webpack:///./node_modules/color-convert/conversions.js","webpack:///./node_modules/color-convert/index.js","webpack:///./node_modules/color-convert/route.js","webpack:///./node_modules/color-name/index.js","webpack:///./node_modules/supports-color/browser.js","webpack:///(webpack)/buildin/module.js"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;AClFA,cAAc,mBAAO,CAAC,mDAAO;AAC7B,8B;;;;;;;;;;;ACDA,mBAAO,CAAC,8EAAe;AACvB,mBAAO,CAAC,0EAAa;AACrB,YAAY,mBAAO,CAAC,oEAAU,E;;;;;;;;;;;ACF9B,uC;;;;;;;;;;;ACAA;AACA;AACA,E;;;;;;;;;;;ACFA,mBAAO,CAAC,sEAAW;AACnB,mBAAO,CAAC,sEAAW,E;;;;;;;;;;;ACDnB,uC;;;;;;;;;;;;ACAA,8CAAa;;AAEb;AACA;AACA,kBAAkB,cAAc;AAChC;;AAEA;AACA;AACA,kBAAkB,aAAa,EAAE,EAAE,KAAK;AACxC;;AAEA;AACA;AACA,kBAAkB,aAAa,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO;AAC9D;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;;AAEJ;AACA,GAAG;AACH;AACA;AACA,EAAE;AACF;;AAEA,WAAW,+BAA+B;AAC1C;AACA;AACA;AACA,iBAAiB,mBAAO,CAAC,4DAAe;AACxC;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,oBAAoB,SAAS;AAC7B,qBAAqB,SAAS;AAC9B;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA,EAAE;;AAEF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,CAAC;;;;;;;;;;;;;;AClKY;AACb,mBAAmB,mBAAO,CAAC,wDAAa;AACxC,OAAO,yCAAyC,GAAG,mBAAO,CAAC,gEAAgB;AAC3E;AACA;AACA;AACA,CAAC,GAAG,mBAAO,CAAC,mDAAQ;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,0CAA0C;AAC1C;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,2CAA2C,eAAe;AAC1D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,0CAA0C,eAAe;AACzD;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,UAAU,MAAM;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU,MAAM;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,8CAA8C;AAC9C;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,2BAA2B;;AAE3B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA,QAAQ,kBAAkB;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,gBAAgB,wBAAwB;AACxC;AACA,yCAAyC;AACzC;AACA;AACA;;AAEA;AACA,aAAa,mBAAO,CAAC,6DAAa;AAClC;;AAEA;AACA;;AAEA;;AAEA,sBAAsB;AACtB;AACA,sBAAsB,2CAA2C,EAAE;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;;ACxOa;AACb,0CAA0C,EAAE,GAAG,QAAQ,IAAI,EAAE,WAAW,EAAE,UAAU,uEAAuE;AAC3J;AACA;AACA,qCAAqC,EAAE,GAAG,QAAQ,IAAI,EAAE,WAAW,EAAE;;AAErE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,4BAA4B;;AAE5B;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH,6DAA6D,MAAM,cAAc,KAAK;AACtF;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,2CAA2C,UAAU;AACrD;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,gBAAgB,mCAAmC;AACnD,GAAG;AACH;AACA,uCAAuC;AACvC;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,EAAE;;AAEF;;AAEA;AACA,sDAAsD,cAAc,kBAAkB,+BAA+B,KAAK;AAC1H;AACA;;AAEA;AACA;;;;;;;;;;;;;ACrIa;;AAEb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;;;;;ACtCA;AACA;AACA,oBAAoB,mBAAO,CAAC,sDAAY;;AAExC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,QAAQ,4BAA4B;AACpC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,2BAA2B;AAClC,OAAO,6BAA6B;AACpC,WAAW,iCAAiC;AAC5C,UAAU,gCAAgC;AAC1C,WAAW,iCAAiC;AAC5C,OAAO,qCAAqC;AAC5C,SAAS,2CAA2C;AACpD,QAAQ;AACR;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,QAAQ,iBAAiB;AACzB;AACA;AACA,oDAAoD,gBAAgB;AACpE,kDAAkD,cAAc;AAChE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,6BAA6B;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,QAAQ,SAAS;AACjC,gBAAgB,QAAQ,SAAS;AACjC,iBAAiB,OAAO,QAAQ;AAChC,iBAAiB,OAAO,QAAQ;AAChC,gBAAgB,SAAS,OAAO;AAChC,gBAAgB,SAAS,OAAO;AAChC;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,yEAAyE;;AAEzE;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,sBAAsB;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,iDAAiD,EAAE,UAAU,EAAE;AAC/D;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA,EAAE;AACF;AACA;AACA,EAAE;AACF;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa,aAAa;AACzC;AACA,eAAe,aAAa;AAC5B;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;;;;;ACt0BA,oBAAoB,mBAAO,CAAC,kEAAe;AAC3C,cAAc,mBAAO,CAAC,sDAAS;;AAE/B;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,kCAAkC;AAClC;AACA;AACA,uCAAuC,SAAS;AAChD;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,wDAAwD,uCAAuC;AAC/F,sDAAsD,qCAAqC;;AAE3F;AACA;;AAEA;AACA;;AAEA;AACA;AACA,EAAE;AACF,CAAC;;AAED;;;;;;;;;;;;AChFA,oBAAoB,mBAAO,CAAC,kEAAe;;AAE3C;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,qCAAqC,SAAS;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,2BAA2B;;AAE3B;;AAEA;AACA;AACA;;AAEA,yCAAyC,SAAS;AAClD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,qCAAqC,SAAS;AAC9C;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;AC/FY;;AAEZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACvJa;AACb;AACA;AACA;AACA;;;;;;;;;;;;ACJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA","file":"d.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./__tests__/fixtures/should-not-omit/shared/mixed.js\");\n","const chalk = require('chalk');\nchalk.green('color it green');","require('./colorful.js');\nrequire('./styles.js');\nconst one = require('./one.js');","// extracted by mini-css-extract-plugin","module.exports = function (){\n\treturn 1;\n};","require('./one.css');\nrequire('./two.css');","// extracted by mini-css-extract-plugin","'use strict';\n\nconst wrapAnsi16 = (fn, offset) => (...args) => {\n\tconst code = fn(...args);\n\treturn `\\u001B[${code + offset}m`;\n};\n\nconst wrapAnsi256 = (fn, offset) => (...args) => {\n\tconst code = fn(...args);\n\treturn `\\u001B[${38 + offset};5;${code}m`;\n};\n\nconst wrapAnsi16m = (fn, offset) => (...args) => {\n\tconst rgb = fn(...args);\n\treturn `\\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;\n};\n\nconst ansi2ansi = n => n;\nconst rgb2rgb = (r, g, b) => [r, g, b];\n\nconst setLazyProperty = (object, property, get) => {\n\tObject.defineProperty(object, property, {\n\t\tget: () => {\n\t\t\tconst value = get();\n\n\t\t\tObject.defineProperty(object, property, {\n\t\t\t\tvalue,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true\n\t\t\t});\n\n\t\t\treturn value;\n\t\t},\n\t\tenumerable: true,\n\t\tconfigurable: true\n\t});\n};\n\n/** @type {typeof import('color-convert')} */\nlet colorConvert;\nconst makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {\n\tif (colorConvert === undefined) {\n\t\tcolorConvert = require('color-convert');\n\t}\n\n\tconst offset = isBackground ? 10 : 0;\n\tconst styles = {};\n\n\tfor (const [sourceSpace, suite] of Object.entries(colorConvert)) {\n\t\tconst name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;\n\t\tif (sourceSpace === targetSpace) {\n\t\t\tstyles[name] = wrap(identity, offset);\n\t\t} else if (typeof suite === 'object') {\n\t\t\tstyles[name] = wrap(suite[targetSpace], offset);\n\t\t}\n\t}\n\n\treturn styles;\n};\n\nfunction assembleStyles() {\n\tconst codes = new Map();\n\tconst styles = {\n\t\tmodifier: {\n\t\t\treset: [0, 0],\n\t\t\t// 21 isn't widely supported and 22 does the same thing\n\t\t\tbold: [1, 22],\n\t\t\tdim: [2, 22],\n\t\t\titalic: [3, 23],\n\t\t\tunderline: [4, 24],\n\t\t\tinverse: [7, 27],\n\t\t\thidden: [8, 28],\n\t\t\tstrikethrough: [9, 29]\n\t\t},\n\t\tcolor: {\n\t\t\tblack: [30, 39],\n\t\t\tred: [31, 39],\n\t\t\tgreen: [32, 39],\n\t\t\tyellow: [33, 39],\n\t\t\tblue: [34, 39],\n\t\t\tmagenta: [35, 39],\n\t\t\tcyan: [36, 39],\n\t\t\twhite: [37, 39],\n\n\t\t\t// Bright color\n\t\t\tblackBright: [90, 39],\n\t\t\tredBright: [91, 39],\n\t\t\tgreenBright: [92, 39],\n\t\t\tyellowBright: [93, 39],\n\t\t\tblueBright: [94, 39],\n\t\t\tmagentaBright: [95, 39],\n\t\t\tcyanBright: [96, 39],\n\t\t\twhiteBright: [97, 39]\n\t\t},\n\t\tbgColor: {\n\t\t\tbgBlack: [40, 49],\n\t\t\tbgRed: [41, 49],\n\t\t\tbgGreen: [42, 49],\n\t\t\tbgYellow: [43, 49],\n\t\t\tbgBlue: [44, 49],\n\t\t\tbgMagenta: [45, 49],\n\t\t\tbgCyan: [46, 49],\n\t\t\tbgWhite: [47, 49],\n\n\t\t\t// Bright color\n\t\t\tbgBlackBright: [100, 49],\n\t\t\tbgRedBright: [101, 49],\n\t\t\tbgGreenBright: [102, 49],\n\t\t\tbgYellowBright: [103, 49],\n\t\t\tbgBlueBright: [104, 49],\n\t\t\tbgMagentaBright: [105, 49],\n\t\t\tbgCyanBright: [106, 49],\n\t\t\tbgWhiteBright: [107, 49]\n\t\t}\n\t};\n\n\t// Alias bright black as gray (and grey)\n\tstyles.color.gray = styles.color.blackBright;\n\tstyles.bgColor.bgGray = styles.bgColor.bgBlackBright;\n\tstyles.color.grey = styles.color.blackBright;\n\tstyles.bgColor.bgGrey = styles.bgColor.bgBlackBright;\n\n\tfor (const [groupName, group] of Object.entries(styles)) {\n\t\tfor (const [styleName, style] of Object.entries(group)) {\n\t\t\tstyles[styleName] = {\n\t\t\t\topen: `\\u001B[${style[0]}m`,\n\t\t\t\tclose: `\\u001B[${style[1]}m`\n\t\t\t};\n\n\t\t\tgroup[styleName] = styles[styleName];\n\n\t\t\tcodes.set(style[0], style[1]);\n\t\t}\n\n\t\tObject.defineProperty(styles, groupName, {\n\t\t\tvalue: group,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tObject.defineProperty(styles, 'codes', {\n\t\tvalue: codes,\n\t\tenumerable: false\n\t});\n\n\tstyles.color.close = '\\u001B[39m';\n\tstyles.bgColor.close = '\\u001B[49m';\n\n\tsetLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));\n\tsetLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));\n\tsetLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));\n\tsetLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));\n\tsetLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));\n\tsetLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));\n\n\treturn styles;\n}\n\n// Make the export immutable\nObject.defineProperty(module, 'exports', {\n\tenumerable: true,\n\tget: assembleStyles\n});\n","'use strict';\nconst ansiStyles = require('ansi-styles');\nconst {stdout: stdoutColor, stderr: stderrColor} = require('supports-color');\nconst {\n\tstringReplaceAll,\n\tstringEncaseCRLFWithFirstIndex\n} = require('./util');\n\n// `supportsColor.level` → `ansiStyles.color[name]` mapping\nconst levelMapping = [\n\t'ansi',\n\t'ansi',\n\t'ansi256',\n\t'ansi16m'\n];\n\nconst styles = Object.create(null);\n\nconst applyOptions = (object, options = {}) => {\n\tif (options.level > 3 || options.level < 0) {\n\t\tthrow new Error('The `level` option should be an integer from 0 to 3');\n\t}\n\n\t// Detect level if not set manually\n\tconst colorLevel = stdoutColor ? stdoutColor.level : 0;\n\tobject.level = options.level === undefined ? colorLevel : options.level;\n};\n\nclass ChalkClass {\n\tconstructor(options) {\n\t\treturn chalkFactory(options);\n\t}\n}\n\nconst chalkFactory = options => {\n\tconst chalk = {};\n\tapplyOptions(chalk, options);\n\n\tchalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);\n\n\tObject.setPrototypeOf(chalk, Chalk.prototype);\n\tObject.setPrototypeOf(chalk.template, chalk);\n\n\tchalk.template.constructor = () => {\n\t\tthrow new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');\n\t};\n\n\tchalk.template.Instance = ChalkClass;\n\n\treturn chalk.template;\n};\n\nfunction Chalk(options) {\n\treturn chalkFactory(options);\n}\n\nfor (const [styleName, style] of Object.entries(ansiStyles)) {\n\tstyles[styleName] = {\n\t\tget() {\n\t\t\tconst builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);\n\t\t\tObject.defineProperty(this, styleName, {value: builder});\n\t\t\treturn builder;\n\t\t}\n\t};\n}\n\nstyles.visible = {\n\tget() {\n\t\tconst builder = createBuilder(this, this._styler, true);\n\t\tObject.defineProperty(this, 'visible', {value: builder});\n\t\treturn builder;\n\t}\n};\n\nconst usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];\n\nfor (const model of usedModels) {\n\tstyles[model] = {\n\t\tget() {\n\t\t\tconst {level} = this;\n\t\t\treturn function (...arguments_) {\n\t\t\t\tconst styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);\n\t\t\t\treturn createBuilder(this, styler, this._isEmpty);\n\t\t\t};\n\t\t}\n\t};\n}\n\nfor (const model of usedModels) {\n\tconst bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);\n\tstyles[bgModel] = {\n\t\tget() {\n\t\t\tconst {level} = this;\n\t\t\treturn function (...arguments_) {\n\t\t\t\tconst styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);\n\t\t\t\treturn createBuilder(this, styler, this._isEmpty);\n\t\t\t};\n\t\t}\n\t};\n}\n\nconst proto = Object.defineProperties(() => {}, {\n\t...styles,\n\tlevel: {\n\t\tenumerable: true,\n\t\tget() {\n\t\t\treturn this._generator.level;\n\t\t},\n\t\tset(level) {\n\t\t\tthis._generator.level = level;\n\t\t}\n\t}\n});\n\nconst createStyler = (open, close, parent) => {\n\tlet openAll;\n\tlet closeAll;\n\tif (parent === undefined) {\n\t\topenAll = open;\n\t\tcloseAll = close;\n\t} else {\n\t\topenAll = parent.openAll + open;\n\t\tcloseAll = close + parent.closeAll;\n\t}\n\n\treturn {\n\t\topen,\n\t\tclose,\n\t\topenAll,\n\t\tcloseAll,\n\t\tparent\n\t};\n};\n\nconst createBuilder = (self, _styler, _isEmpty) => {\n\tconst builder = (...arguments_) => {\n\t\t// Single argument is hot path, implicit coercion is faster than anything\n\t\t// eslint-disable-next-line no-implicit-coercion\n\t\treturn applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));\n\t};\n\n\t// `__proto__` is used because we must return a function, but there is\n\t// no way to create a function with a different prototype\n\tbuilder.__proto__ = proto; // eslint-disable-line no-proto\n\n\tbuilder._generator = self;\n\tbuilder._styler = _styler;\n\tbuilder._isEmpty = _isEmpty;\n\n\treturn builder;\n};\n\nconst applyStyle = (self, string) => {\n\tif (self.level <= 0 || !string) {\n\t\treturn self._isEmpty ? '' : string;\n\t}\n\n\tlet styler = self._styler;\n\n\tif (styler === undefined) {\n\t\treturn string;\n\t}\n\n\tconst {openAll, closeAll} = styler;\n\tif (string.indexOf('\\u001B') !== -1) {\n\t\twhile (styler !== undefined) {\n\t\t\t// Replace any instances already present with a re-opening code\n\t\t\t// otherwise only the part of the string until said closing code\n\t\t\t// will be colored, and the rest will simply be 'plain'.\n\t\t\tstring = stringReplaceAll(string, styler.close, styler.open);\n\n\t\t\tstyler = styler.parent;\n\t\t}\n\t}\n\n\t// We can move both next actions out of loop, because remaining actions in loop won't have\n\t// any/visible effect on parts we add here. Close the styling before a linebreak and reopen\n\t// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92\n\tconst lfIndex = string.indexOf('\\n');\n\tif (lfIndex !== -1) {\n\t\tstring = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);\n\t}\n\n\treturn openAll + string + closeAll;\n};\n\nlet template;\nconst chalkTag = (chalk, ...strings) => {\n\tconst [firstString] = strings;\n\n\tif (!Array.isArray(firstString)) {\n\t\t// If chalk() was called by itself or with a string,\n\t\t// return the string itself as a string.\n\t\treturn strings.join(' ');\n\t}\n\n\tconst arguments_ = strings.slice(1);\n\tconst parts = [firstString.raw[0]];\n\n\tfor (let i = 1; i < firstString.length; i++) {\n\t\tparts.push(\n\t\t\tString(arguments_[i - 1]).replace(/[{}\\\\]/g, '\\\\$&'),\n\t\t\tString(firstString.raw[i])\n\t\t);\n\t}\n\n\tif (template === undefined) {\n\t\ttemplate = require('./templates');\n\t}\n\n\treturn template(chalk, parts.join(''));\n};\n\nObject.defineProperties(Chalk.prototype, styles);\n\nconst chalk = Chalk(); // eslint-disable-line new-cap\nchalk.supportsColor = stdoutColor;\nchalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap\nchalk.stderr.supportsColor = stderrColor;\n\n// For TypeScript\nchalk.Level = {\n\tNone: 0,\n\tBasic: 1,\n\tAnsi256: 2,\n\tTrueColor: 3,\n\t0: 'None',\n\t1: 'Basic',\n\t2: 'Ansi256',\n\t3: 'TrueColor'\n};\n\nmodule.exports = chalk;\n","'use strict';\nconst TEMPLATE_REGEX = /(?:\\\\(u(?:[a-f\\d]{4}|\\{[a-f\\d]{1,6}\\})|x[a-f\\d]{2}|.))|(?:\\{(~)?(\\w+(?:\\([^)]*\\))?(?:\\.\\w+(?:\\([^)]*\\))?)*)(?:[ \\t]|(?=\\r?\\n)))|(\\})|((?:.|[\\r\\n\\f])+?)/gi;\nconst STYLE_REGEX = /(?:^|\\.)(\\w+)(?:\\(([^)]*)\\))?/g;\nconst STRING_REGEX = /^(['\"])((?:\\\\.|(?!\\1)[^\\\\])*)\\1$/;\nconst ESCAPE_REGEX = /\\\\(u(?:[a-f\\d]{4}|\\{[a-f\\d]{1,6}\\})|x[a-f\\d]{2}|.)|([^\\\\])/gi;\n\nconst ESCAPES = new Map([\n\t['n', '\\n'],\n\t['r', '\\r'],\n\t['t', '\\t'],\n\t['b', '\\b'],\n\t['f', '\\f'],\n\t['v', '\\v'],\n\t['0', '\\0'],\n\t['\\\\', '\\\\'],\n\t['e', '\\u001B'],\n\t['a', '\\u0007']\n]);\n\nfunction unescape(c) {\n\tconst u = c[0] === 'u';\n\tconst bracket = c[1] === '{';\n\n\tif ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {\n\t\treturn String.fromCharCode(parseInt(c.slice(1), 16));\n\t}\n\n\tif (u && bracket) {\n\t\treturn String.fromCodePoint(parseInt(c.slice(2, -1), 16));\n\t}\n\n\treturn ESCAPES.get(c) || c;\n}\n\nfunction parseArguments(name, arguments_) {\n\tconst results = [];\n\tconst chunks = arguments_.trim().split(/\\s*,\\s*/g);\n\tlet matches;\n\n\tfor (const chunk of chunks) {\n\t\tconst number = Number(chunk);\n\t\tif (!Number.isNaN(number)) {\n\t\t\tresults.push(number);\n\t\t} else if ((matches = chunk.match(STRING_REGEX))) {\n\t\t\tresults.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));\n\t\t} else {\n\t\t\tthrow new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);\n\t\t}\n\t}\n\n\treturn results;\n}\n\nfunction parseStyle(style) {\n\tSTYLE_REGEX.lastIndex = 0;\n\n\tconst results = [];\n\tlet matches;\n\n\twhile ((matches = STYLE_REGEX.exec(style)) !== null) {\n\t\tconst name = matches[1];\n\n\t\tif (matches[2]) {\n\t\t\tconst args = parseArguments(name, matches[2]);\n\t\t\tresults.push([name].concat(args));\n\t\t} else {\n\t\t\tresults.push([name]);\n\t\t}\n\t}\n\n\treturn results;\n}\n\nfunction buildStyle(chalk, styles) {\n\tconst enabled = {};\n\n\tfor (const layer of styles) {\n\t\tfor (const style of layer.styles) {\n\t\t\tenabled[style[0]] = layer.inverse ? null : style.slice(1);\n\t\t}\n\t}\n\n\tlet current = chalk;\n\tfor (const [styleName, styles] of Object.entries(enabled)) {\n\t\tif (!Array.isArray(styles)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!(styleName in current)) {\n\t\t\tthrow new Error(`Unknown Chalk style: ${styleName}`);\n\t\t}\n\n\t\tcurrent = styles.length > 0 ? current[styleName](...styles) : current[styleName];\n\t}\n\n\treturn current;\n}\n\nmodule.exports = (chalk, temporary) => {\n\tconst styles = [];\n\tconst chunks = [];\n\tlet chunk = [];\n\n\t// eslint-disable-next-line max-params\n\ttemporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {\n\t\tif (escapeCharacter) {\n\t\t\tchunk.push(unescape(escapeCharacter));\n\t\t} else if (style) {\n\t\t\tconst string = chunk.join('');\n\t\t\tchunk = [];\n\t\t\tchunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));\n\t\t\tstyles.push({inverse, styles: parseStyle(style)});\n\t\t} else if (close) {\n\t\t\tif (styles.length === 0) {\n\t\t\t\tthrow new Error('Found extraneous } in Chalk template literal');\n\t\t\t}\n\n\t\t\tchunks.push(buildStyle(chalk, styles)(chunk.join('')));\n\t\t\tchunk = [];\n\t\t\tstyles.pop();\n\t\t} else {\n\t\t\tchunk.push(character);\n\t\t}\n\t});\n\n\tchunks.push(chunk.join(''));\n\n\tif (styles.length > 0) {\n\t\tconst errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\\`}\\`)`;\n\t\tthrow new Error(errMsg);\n\t}\n\n\treturn chunks.join('');\n};\n","'use strict';\n\nconst stringReplaceAll = (string, substring, replacer) => {\n\tlet index = string.indexOf(substring);\n\tif (index === -1) {\n\t\treturn string;\n\t}\n\n\tconst substringLength = substring.length;\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\treturnValue += string.substr(endIndex, index - endIndex) + substring + replacer;\n\t\tendIndex = index + substringLength;\n\t\tindex = string.indexOf(substring, endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.substr(endIndex);\n\treturn returnValue;\n};\n\nconst stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\tconst gotCR = string[index - 1] === '\\r';\n\t\treturnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\\r\\n' : '\\n') + postfix;\n\t\tendIndex = index + 1;\n\t\tindex = string.indexOf('\\n', endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.substr(endIndex);\n\treturn returnValue;\n};\n\nmodule.exports = {\n\tstringReplaceAll,\n\tstringEncaseCRLFWithFirstIndex\n};\n","/* MIT license */\n/* eslint-disable no-mixed-operators */\nconst cssKeywords = require('color-name');\n\n// NOTE: conversions should only return primitive values (i.e. arrays, or\n// values that give correct `typeof` results).\n// do not use box values types (i.e. Number(), String(), etc.)\n\nconst reverseKeywords = {};\nfor (const key of Object.keys(cssKeywords)) {\n\treverseKeywords[cssKeywords[key]] = key;\n}\n\nconst convert = {\n\trgb: {channels: 3, labels: 'rgb'},\n\thsl: {channels: 3, labels: 'hsl'},\n\thsv: {channels: 3, labels: 'hsv'},\n\thwb: {channels: 3, labels: 'hwb'},\n\tcmyk: {channels: 4, labels: 'cmyk'},\n\txyz: {channels: 3, labels: 'xyz'},\n\tlab: {channels: 3, labels: 'lab'},\n\tlch: {channels: 3, labels: 'lch'},\n\thex: {channels: 1, labels: ['hex']},\n\tkeyword: {channels: 1, labels: ['keyword']},\n\tansi16: {channels: 1, labels: ['ansi16']},\n\tansi256: {channels: 1, labels: ['ansi256']},\n\thcg: {channels: 3, labels: ['h', 'c', 'g']},\n\tapple: {channels: 3, labels: ['r16', 'g16', 'b16']},\n\tgray: {channels: 1, labels: ['gray']}\n};\n\nmodule.exports = convert;\n\n// Hide .channels and .labels properties\nfor (const model of Object.keys(convert)) {\n\tif (!('channels' in convert[model])) {\n\t\tthrow new Error('missing channels property: ' + model);\n\t}\n\n\tif (!('labels' in convert[model])) {\n\t\tthrow new Error('missing channel labels property: ' + model);\n\t}\n\n\tif (convert[model].labels.length !== convert[model].channels) {\n\t\tthrow new Error('channel and label counts mismatch: ' + model);\n\t}\n\n\tconst {channels, labels} = convert[model];\n\tdelete convert[model].channels;\n\tdelete convert[model].labels;\n\tObject.defineProperty(convert[model], 'channels', {value: channels});\n\tObject.defineProperty(convert[model], 'labels', {value: labels});\n}\n\nconvert.rgb.hsl = function (rgb) {\n\tconst r = rgb[0] / 255;\n\tconst g = rgb[1] / 255;\n\tconst b = rgb[2] / 255;\n\tconst min = Math.min(r, g, b);\n\tconst max = Math.max(r, g, b);\n\tconst delta = max - min;\n\tlet h;\n\tlet s;\n\n\tif (max === min) {\n\t\th = 0;\n\t} else if (r === max) {\n\t\th = (g - b) / delta;\n\t} else if (g === max) {\n\t\th = 2 + (b - r) / delta;\n\t} else if (b === max) {\n\t\th = 4 + (r - g) / delta;\n\t}\n\n\th = Math.min(h * 60, 360);\n\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\tconst l = (min + max) / 2;\n\n\tif (max === min) {\n\t\ts = 0;\n\t} else if (l <= 0.5) {\n\t\ts = delta / (max + min);\n\t} else {\n\t\ts = delta / (2 - max - min);\n\t}\n\n\treturn [h, s * 100, l * 100];\n};\n\nconvert.rgb.hsv = function (rgb) {\n\tlet rdif;\n\tlet gdif;\n\tlet bdif;\n\tlet h;\n\tlet s;\n\n\tconst r = rgb[0] / 255;\n\tconst g = rgb[1] / 255;\n\tconst b = rgb[2] / 255;\n\tconst v = Math.max(r, g, b);\n\tconst diff = v - Math.min(r, g, b);\n\tconst diffc = function (c) {\n\t\treturn (v - c) / 6 / diff + 1 / 2;\n\t};\n\n\tif (diff === 0) {\n\t\th = 0;\n\t\ts = 0;\n\t} else {\n\t\ts = diff / v;\n\t\trdif = diffc(r);\n\t\tgdif = diffc(g);\n\t\tbdif = diffc(b);\n\n\t\tif (r === v) {\n\t\t\th = bdif - gdif;\n\t\t} else if (g === v) {\n\t\t\th = (1 / 3) + rdif - bdif;\n\t\t} else if (b === v) {\n\t\t\th = (2 / 3) + gdif - rdif;\n\t\t}\n\n\t\tif (h < 0) {\n\t\t\th += 1;\n\t\t} else if (h > 1) {\n\t\t\th -= 1;\n\t\t}\n\t}\n\n\treturn [\n\t\th * 360,\n\t\ts * 100,\n\t\tv * 100\n\t];\n};\n\nconvert.rgb.hwb = function (rgb) {\n\tconst r = rgb[0];\n\tconst g = rgb[1];\n\tlet b = rgb[2];\n\tconst h = convert.rgb.hsl(rgb)[0];\n\tconst w = 1 / 255 * Math.min(r, Math.min(g, b));\n\n\tb = 1 - 1 / 255 * Math.max(r, Math.max(g, b));\n\n\treturn [h, w * 100, b * 100];\n};\n\nconvert.rgb.cmyk = function (rgb) {\n\tconst r = rgb[0] / 255;\n\tconst g = rgb[1] / 255;\n\tconst b = rgb[2] / 255;\n\n\tconst k = Math.min(1 - r, 1 - g, 1 - b);\n\tconst c = (1 - r - k) / (1 - k) || 0;\n\tconst m = (1 - g - k) / (1 - k) || 0;\n\tconst y = (1 - b - k) / (1 - k) || 0;\n\n\treturn [c * 100, m * 100, y * 100, k * 100];\n};\n\nfunction comparativeDistance(x, y) {\n\t/*\n\t\tSee https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance\n\t*/\n\treturn (\n\t\t((x[0] - y[0]) ** 2) +\n\t\t((x[1] - y[1]) ** 2) +\n\t\t((x[2] - y[2]) ** 2)\n\t);\n}\n\nconvert.rgb.keyword = function (rgb) {\n\tconst reversed = reverseKeywords[rgb];\n\tif (reversed) {\n\t\treturn reversed;\n\t}\n\n\tlet currentClosestDistance = Infinity;\n\tlet currentClosestKeyword;\n\n\tfor (const keyword of Object.keys(cssKeywords)) {\n\t\tconst value = cssKeywords[keyword];\n\n\t\t// Compute comparative distance\n\t\tconst distance = comparativeDistance(rgb, value);\n\n\t\t// Check if its less, if so set as closest\n\t\tif (distance < currentClosestDistance) {\n\t\t\tcurrentClosestDistance = distance;\n\t\t\tcurrentClosestKeyword = keyword;\n\t\t}\n\t}\n\n\treturn currentClosestKeyword;\n};\n\nconvert.keyword.rgb = function (keyword) {\n\treturn cssKeywords[keyword];\n};\n\nconvert.rgb.xyz = function (rgb) {\n\tlet r = rgb[0] / 255;\n\tlet g = rgb[1] / 255;\n\tlet b = rgb[2] / 255;\n\n\t// Assume sRGB\n\tr = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);\n\tg = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);\n\tb = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);\n\n\tconst x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);\n\tconst y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);\n\tconst z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);\n\n\treturn [x * 100, y * 100, z * 100];\n};\n\nconvert.rgb.lab = function (rgb) {\n\tconst xyz = convert.rgb.xyz(rgb);\n\tlet x = xyz[0];\n\tlet y = xyz[1];\n\tlet z = xyz[2];\n\n\tx /= 95.047;\n\ty /= 100;\n\tz /= 108.883;\n\n\tx = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);\n\ty = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);\n\tz = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);\n\n\tconst l = (116 * y) - 16;\n\tconst a = 500 * (x - y);\n\tconst b = 200 * (y - z);\n\n\treturn [l, a, b];\n};\n\nconvert.hsl.rgb = function (hsl) {\n\tconst h = hsl[0] / 360;\n\tconst s = hsl[1] / 100;\n\tconst l = hsl[2] / 100;\n\tlet t2;\n\tlet t3;\n\tlet val;\n\n\tif (s === 0) {\n\t\tval = l * 255;\n\t\treturn [val, val, val];\n\t}\n\n\tif (l < 0.5) {\n\t\tt2 = l * (1 + s);\n\t} else {\n\t\tt2 = l + s - l * s;\n\t}\n\n\tconst t1 = 2 * l - t2;\n\n\tconst rgb = [0, 0, 0];\n\tfor (let i = 0; i < 3; i++) {\n\t\tt3 = h + 1 / 3 * -(i - 1);\n\t\tif (t3 < 0) {\n\t\t\tt3++;\n\t\t}\n\n\t\tif (t3 > 1) {\n\t\t\tt3--;\n\t\t}\n\n\t\tif (6 * t3 < 1) {\n\t\t\tval = t1 + (t2 - t1) * 6 * t3;\n\t\t} else if (2 * t3 < 1) {\n\t\t\tval = t2;\n\t\t} else if (3 * t3 < 2) {\n\t\t\tval = t1 + (t2 - t1) * (2 / 3 - t3) * 6;\n\t\t} else {\n\t\t\tval = t1;\n\t\t}\n\n\t\trgb[i] = val * 255;\n\t}\n\n\treturn rgb;\n};\n\nconvert.hsl.hsv = function (hsl) {\n\tconst h = hsl[0];\n\tlet s = hsl[1] / 100;\n\tlet l = hsl[2] / 100;\n\tlet smin = s;\n\tconst lmin = Math.max(l, 0.01);\n\n\tl *= 2;\n\ts *= (l <= 1) ? l : 2 - l;\n\tsmin *= lmin <= 1 ? lmin : 2 - lmin;\n\tconst v = (l + s) / 2;\n\tconst sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);\n\n\treturn [h, sv * 100, v * 100];\n};\n\nconvert.hsv.rgb = function (hsv) {\n\tconst h = hsv[0] / 60;\n\tconst s = hsv[1] / 100;\n\tlet v = hsv[2] / 100;\n\tconst hi = Math.floor(h) % 6;\n\n\tconst f = h - Math.floor(h);\n\tconst p = 255 * v * (1 - s);\n\tconst q = 255 * v * (1 - (s * f));\n\tconst t = 255 * v * (1 - (s * (1 - f)));\n\tv *= 255;\n\n\tswitch (hi) {\n\t\tcase 0:\n\t\t\treturn [v, t, p];\n\t\tcase 1:\n\t\t\treturn [q, v, p];\n\t\tcase 2:\n\t\t\treturn [p, v, t];\n\t\tcase 3:\n\t\t\treturn [p, q, v];\n\t\tcase 4:\n\t\t\treturn [t, p, v];\n\t\tcase 5:\n\t\t\treturn [v, p, q];\n\t}\n};\n\nconvert.hsv.hsl = function (hsv) {\n\tconst h = hsv[0];\n\tconst s = hsv[1] / 100;\n\tconst v = hsv[2] / 100;\n\tconst vmin = Math.max(v, 0.01);\n\tlet sl;\n\tlet l;\n\n\tl = (2 - s) * v;\n\tconst lmin = (2 - s) * vmin;\n\tsl = s * vmin;\n\tsl /= (lmin <= 1) ? lmin : 2 - lmin;\n\tsl = sl || 0;\n\tl /= 2;\n\n\treturn [h, sl * 100, l * 100];\n};\n\n// http://dev.w3.org/csswg/css-color/#hwb-to-rgb\nconvert.hwb.rgb = function (hwb) {\n\tconst h = hwb[0] / 360;\n\tlet wh = hwb[1] / 100;\n\tlet bl = hwb[2] / 100;\n\tconst ratio = wh + bl;\n\tlet f;\n\n\t// Wh + bl cant be > 1\n\tif (ratio > 1) {\n\t\twh /= ratio;\n\t\tbl /= ratio;\n\t}\n\n\tconst i = Math.floor(6 * h);\n\tconst v = 1 - bl;\n\tf = 6 * h - i;\n\n\tif ((i & 0x01) !== 0) {\n\t\tf = 1 - f;\n\t}\n\n\tconst n = wh + f * (v - wh); // Linear interpolation\n\n\tlet r;\n\tlet g;\n\tlet b;\n\t/* eslint-disable max-statements-per-line,no-multi-spaces */\n\tswitch (i) {\n\t\tdefault:\n\t\tcase 6:\n\t\tcase 0: r = v; g = n; b = wh; break;\n\t\tcase 1: r = n; g = v; b = wh; break;\n\t\tcase 2: r = wh; g = v; b = n; break;\n\t\tcase 3: r = wh; g = n; b = v; break;\n\t\tcase 4: r = n; g = wh; b = v; break;\n\t\tcase 5: r = v; g = wh; b = n; break;\n\t}\n\t/* eslint-enable max-statements-per-line,no-multi-spaces */\n\n\treturn [r * 255, g * 255, b * 255];\n};\n\nconvert.cmyk.rgb = function (cmyk) {\n\tconst c = cmyk[0] / 100;\n\tconst m = cmyk[1] / 100;\n\tconst y = cmyk[2] / 100;\n\tconst k = cmyk[3] / 100;\n\n\tconst r = 1 - Math.min(1, c * (1 - k) + k);\n\tconst g = 1 - Math.min(1, m * (1 - k) + k);\n\tconst b = 1 - Math.min(1, y * (1 - k) + k);\n\n\treturn [r * 255, g * 255, b * 255];\n};\n\nconvert.xyz.rgb = function (xyz) {\n\tconst x = xyz[0] / 100;\n\tconst y = xyz[1] / 100;\n\tconst z = xyz[2] / 100;\n\tlet r;\n\tlet g;\n\tlet b;\n\n\tr = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);\n\tg = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);\n\tb = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);\n\n\t// Assume sRGB\n\tr = r > 0.0031308\n\t\t? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)\n\t\t: r * 12.92;\n\n\tg = g > 0.0031308\n\t\t? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)\n\t\t: g * 12.92;\n\n\tb = b > 0.0031308\n\t\t? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)\n\t\t: b * 12.92;\n\n\tr = Math.min(Math.max(0, r), 1);\n\tg = Math.min(Math.max(0, g), 1);\n\tb = Math.min(Math.max(0, b), 1);\n\n\treturn [r * 255, g * 255, b * 255];\n};\n\nconvert.xyz.lab = function (xyz) {\n\tlet x = xyz[0];\n\tlet y = xyz[1];\n\tlet z = xyz[2];\n\n\tx /= 95.047;\n\ty /= 100;\n\tz /= 108.883;\n\n\tx = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);\n\ty = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);\n\tz = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);\n\n\tconst l = (116 * y) - 16;\n\tconst a = 500 * (x - y);\n\tconst b = 200 * (y - z);\n\n\treturn [l, a, b];\n};\n\nconvert.lab.xyz = function (lab) {\n\tconst l = lab[0];\n\tconst a = lab[1];\n\tconst b = lab[2];\n\tlet x;\n\tlet y;\n\tlet z;\n\n\ty = (l + 16) / 116;\n\tx = a / 500 + y;\n\tz = y - b / 200;\n\n\tconst y2 = y ** 3;\n\tconst x2 = x ** 3;\n\tconst z2 = z ** 3;\n\ty = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;\n\tx = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;\n\tz = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;\n\n\tx *= 95.047;\n\ty *= 100;\n\tz *= 108.883;\n\n\treturn [x, y, z];\n};\n\nconvert.lab.lch = function (lab) {\n\tconst l = lab[0];\n\tconst a = lab[1];\n\tconst b = lab[2];\n\tlet h;\n\n\tconst hr = Math.atan2(b, a);\n\th = hr * 360 / 2 / Math.PI;\n\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\tconst c = Math.sqrt(a * a + b * b);\n\n\treturn [l, c, h];\n};\n\nconvert.lch.lab = function (lch) {\n\tconst l = lch[0];\n\tconst c = lch[1];\n\tconst h = lch[2];\n\n\tconst hr = h / 360 * 2 * Math.PI;\n\tconst a = c * Math.cos(hr);\n\tconst b = c * Math.sin(hr);\n\n\treturn [l, a, b];\n};\n\nconvert.rgb.ansi16 = function (args, saturation = null) {\n\tconst [r, g, b] = args;\n\tlet value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization\n\n\tvalue = Math.round(value / 50);\n\n\tif (value === 0) {\n\t\treturn 30;\n\t}\n\n\tlet ansi = 30\n\t\t+ ((Math.round(b / 255) << 2)\n\t\t| (Math.round(g / 255) << 1)\n\t\t| Math.round(r / 255));\n\n\tif (value === 2) {\n\t\tansi += 60;\n\t}\n\n\treturn ansi;\n};\n\nconvert.hsv.ansi16 = function (args) {\n\t// Optimization here; we already know the value and don't need to get\n\t// it converted for us.\n\treturn convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);\n};\n\nconvert.rgb.ansi256 = function (args) {\n\tconst r = args[0];\n\tconst g = args[1];\n\tconst b = args[2];\n\n\t// We use the extended greyscale palette here, with the exception of\n\t// black and white. normal palette only has 4 greyscale shades.\n\tif (r === g && g === b) {\n\t\tif (r < 8) {\n\t\t\treturn 16;\n\t\t}\n\n\t\tif (r > 248) {\n\t\t\treturn 231;\n\t\t}\n\n\t\treturn Math.round(((r - 8) / 247) * 24) + 232;\n\t}\n\n\tconst ansi = 16\n\t\t+ (36 * Math.round(r / 255 * 5))\n\t\t+ (6 * Math.round(g / 255 * 5))\n\t\t+ Math.round(b / 255 * 5);\n\n\treturn ansi;\n};\n\nconvert.ansi16.rgb = function (args) {\n\tlet color = args % 10;\n\n\t// Handle greyscale\n\tif (color === 0 || color === 7) {\n\t\tif (args > 50) {\n\t\t\tcolor += 3.5;\n\t\t}\n\n\t\tcolor = color / 10.5 * 255;\n\n\t\treturn [color, color, color];\n\t}\n\n\tconst mult = (~~(args > 50) + 1) * 0.5;\n\tconst r = ((color & 1) * mult) * 255;\n\tconst g = (((color >> 1) & 1) * mult) * 255;\n\tconst b = (((color >> 2) & 1) * mult) * 255;\n\n\treturn [r, g, b];\n};\n\nconvert.ansi256.rgb = function (args) {\n\t// Handle greyscale\n\tif (args >= 232) {\n\t\tconst c = (args - 232) * 10 + 8;\n\t\treturn [c, c, c];\n\t}\n\n\targs -= 16;\n\n\tlet rem;\n\tconst r = Math.floor(args / 36) / 5 * 255;\n\tconst g = Math.floor((rem = args % 36) / 6) / 5 * 255;\n\tconst b = (rem % 6) / 5 * 255;\n\n\treturn [r, g, b];\n};\n\nconvert.rgb.hex = function (args) {\n\tconst integer = ((Math.round(args[0]) & 0xFF) << 16)\n\t\t+ ((Math.round(args[1]) & 0xFF) << 8)\n\t\t+ (Math.round(args[2]) & 0xFF);\n\n\tconst string = integer.toString(16).toUpperCase();\n\treturn '000000'.substring(string.length) + string;\n};\n\nconvert.hex.rgb = function (args) {\n\tconst match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);\n\tif (!match) {\n\t\treturn [0, 0, 0];\n\t}\n\n\tlet colorString = match[0];\n\n\tif (match[0].length === 3) {\n\t\tcolorString = colorString.split('').map(char => {\n\t\t\treturn char + char;\n\t\t}).join('');\n\t}\n\n\tconst integer = parseInt(colorString, 16);\n\tconst r = (integer >> 16) & 0xFF;\n\tconst g = (integer >> 8) & 0xFF;\n\tconst b = integer & 0xFF;\n\n\treturn [r, g, b];\n};\n\nconvert.rgb.hcg = function (rgb) {\n\tconst r = rgb[0] / 255;\n\tconst g = rgb[1] / 255;\n\tconst b = rgb[2] / 255;\n\tconst max = Math.max(Math.max(r, g), b);\n\tconst min = Math.min(Math.min(r, g), b);\n\tconst chroma = (max - min);\n\tlet grayscale;\n\tlet hue;\n\n\tif (chroma < 1) {\n\t\tgrayscale = min / (1 - chroma);\n\t} else {\n\t\tgrayscale = 0;\n\t}\n\n\tif (chroma <= 0) {\n\t\thue = 0;\n\t} else\n\tif (max === r) {\n\t\thue = ((g - b) / chroma) % 6;\n\t} else\n\tif (max === g) {\n\t\thue = 2 + (b - r) / chroma;\n\t} else {\n\t\thue = 4 + (r - g) / chroma;\n\t}\n\n\thue /= 6;\n\thue %= 1;\n\n\treturn [hue * 360, chroma * 100, grayscale * 100];\n};\n\nconvert.hsl.hcg = function (hsl) {\n\tconst s = hsl[1] / 100;\n\tconst l = hsl[2] / 100;\n\n\tconst c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));\n\n\tlet f = 0;\n\tif (c < 1.0) {\n\t\tf = (l - 0.5 * c) / (1.0 - c);\n\t}\n\n\treturn [hsl[0], c * 100, f * 100];\n};\n\nconvert.hsv.hcg = function (hsv) {\n\tconst s = hsv[1] / 100;\n\tconst v = hsv[2] / 100;\n\n\tconst c = s * v;\n\tlet f = 0;\n\n\tif (c < 1.0) {\n\t\tf = (v - c) / (1 - c);\n\t}\n\n\treturn [hsv[0], c * 100, f * 100];\n};\n\nconvert.hcg.rgb = function (hcg) {\n\tconst h = hcg[0] / 360;\n\tconst c = hcg[1] / 100;\n\tconst g = hcg[2] / 100;\n\n\tif (c === 0.0) {\n\t\treturn [g * 255, g * 255, g * 255];\n\t}\n\n\tconst pure = [0, 0, 0];\n\tconst hi = (h % 1) * 6;\n\tconst v = hi % 1;\n\tconst w = 1 - v;\n\tlet mg = 0;\n\n\t/* eslint-disable max-statements-per-line */\n\tswitch (Math.floor(hi)) {\n\t\tcase 0:\n\t\t\tpure[0] = 1; pure[1] = v; pure[2] = 0; break;\n\t\tcase 1:\n\t\t\tpure[0] = w; pure[1] = 1; pure[2] = 0; break;\n\t\tcase 2:\n\t\t\tpure[0] = 0; pure[1] = 1; pure[2] = v; break;\n\t\tcase 3:\n\t\t\tpure[0] = 0; pure[1] = w; pure[2] = 1; break;\n\t\tcase 4:\n\t\t\tpure[0] = v; pure[1] = 0; pure[2] = 1; break;\n\t\tdefault:\n\t\t\tpure[0] = 1; pure[1] = 0; pure[2] = w;\n\t}\n\t/* eslint-enable max-statements-per-line */\n\n\tmg = (1.0 - c) * g;\n\n\treturn [\n\t\t(c * pure[0] + mg) * 255,\n\t\t(c * pure[1] + mg) * 255,\n\t\t(c * pure[2] + mg) * 255\n\t];\n};\n\nconvert.hcg.hsv = function (hcg) {\n\tconst c = hcg[1] / 100;\n\tconst g = hcg[2] / 100;\n\n\tconst v = c + g * (1.0 - c);\n\tlet f = 0;\n\n\tif (v > 0.0) {\n\t\tf = c / v;\n\t}\n\n\treturn [hcg[0], f * 100, v * 100];\n};\n\nconvert.hcg.hsl = function (hcg) {\n\tconst c = hcg[1] / 100;\n\tconst g = hcg[2] / 100;\n\n\tconst l = g * (1.0 - c) + 0.5 * c;\n\tlet s = 0;\n\n\tif (l > 0.0 && l < 0.5) {\n\t\ts = c / (2 * l);\n\t} else\n\tif (l >= 0.5 && l < 1.0) {\n\t\ts = c / (2 * (1 - l));\n\t}\n\n\treturn [hcg[0], s * 100, l * 100];\n};\n\nconvert.hcg.hwb = function (hcg) {\n\tconst c = hcg[1] / 100;\n\tconst g = hcg[2] / 100;\n\tconst v = c + g * (1.0 - c);\n\treturn [hcg[0], (v - c) * 100, (1 - v) * 100];\n};\n\nconvert.hwb.hcg = function (hwb) {\n\tconst w = hwb[1] / 100;\n\tconst b = hwb[2] / 100;\n\tconst v = 1 - b;\n\tconst c = v - w;\n\tlet g = 0;\n\n\tif (c < 1) {\n\t\tg = (v - c) / (1 - c);\n\t}\n\n\treturn [hwb[0], c * 100, g * 100];\n};\n\nconvert.apple.rgb = function (apple) {\n\treturn [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];\n};\n\nconvert.rgb.apple = function (rgb) {\n\treturn [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];\n};\n\nconvert.gray.rgb = function (args) {\n\treturn [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];\n};\n\nconvert.gray.hsl = function (args) {\n\treturn [0, 0, args[0]];\n};\n\nconvert.gray.hsv = convert.gray.hsl;\n\nconvert.gray.hwb = function (gray) {\n\treturn [0, 100, gray[0]];\n};\n\nconvert.gray.cmyk = function (gray) {\n\treturn [0, 0, 0, gray[0]];\n};\n\nconvert.gray.lab = function (gray) {\n\treturn [gray[0], 0, 0];\n};\n\nconvert.gray.hex = function (gray) {\n\tconst val = Math.round(gray[0] / 100 * 255) & 0xFF;\n\tconst integer = (val << 16) + (val << 8) + val;\n\n\tconst string = integer.toString(16).toUpperCase();\n\treturn '000000'.substring(string.length) + string;\n};\n\nconvert.rgb.gray = function (rgb) {\n\tconst val = (rgb[0] + rgb[1] + rgb[2]) / 3;\n\treturn [val / 255 * 100];\n};\n","const conversions = require('./conversions');\nconst route = require('./route');\n\nconst convert = {};\n\nconst models = Object.keys(conversions);\n\nfunction wrapRaw(fn) {\n\tconst wrappedFn = function (...args) {\n\t\tconst arg0 = args[0];\n\t\tif (arg0 === undefined || arg0 === null) {\n\t\t\treturn arg0;\n\t\t}\n\n\t\tif (arg0.length > 1) {\n\t\t\targs = arg0;\n\t\t}\n\n\t\treturn fn(args);\n\t};\n\n\t// Preserve .conversion property if there is one\n\tif ('conversion' in fn) {\n\t\twrappedFn.conversion = fn.conversion;\n\t}\n\n\treturn wrappedFn;\n}\n\nfunction wrapRounded(fn) {\n\tconst wrappedFn = function (...args) {\n\t\tconst arg0 = args[0];\n\n\t\tif (arg0 === undefined || arg0 === null) {\n\t\t\treturn arg0;\n\t\t}\n\n\t\tif (arg0.length > 1) {\n\t\t\targs = arg0;\n\t\t}\n\n\t\tconst result = fn(args);\n\n\t\t// We're assuming the result is an array here.\n\t\t// see notice in conversions.js; don't use box types\n\t\t// in conversion functions.\n\t\tif (typeof result === 'object') {\n\t\t\tfor (let len = result.length, i = 0; i < len; i++) {\n\t\t\t\tresult[i] = Math.round(result[i]);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t};\n\n\t// Preserve .conversion property if there is one\n\tif ('conversion' in fn) {\n\t\twrappedFn.conversion = fn.conversion;\n\t}\n\n\treturn wrappedFn;\n}\n\nmodels.forEach(fromModel => {\n\tconvert[fromModel] = {};\n\n\tObject.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});\n\tObject.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});\n\n\tconst routes = route(fromModel);\n\tconst routeModels = Object.keys(routes);\n\n\trouteModels.forEach(toModel => {\n\t\tconst fn = routes[toModel];\n\n\t\tconvert[fromModel][toModel] = wrapRounded(fn);\n\t\tconvert[fromModel][toModel].raw = wrapRaw(fn);\n\t});\n});\n\nmodule.exports = convert;\n","const conversions = require('./conversions');\n\n/*\n\tThis function routes a model to all other models.\n\n\tall functions that are routed have a property `.conversion` attached\n\tto the returned synthetic function. This property is an array\n\tof strings, each with the steps in between the 'from' and 'to'\n\tcolor models (inclusive).\n\n\tconversions that are not possible simply are not included.\n*/\n\nfunction buildGraph() {\n\tconst graph = {};\n\t// https://jsperf.com/object-keys-vs-for-in-with-closure/3\n\tconst models = Object.keys(conversions);\n\n\tfor (let len = models.length, i = 0; i < len; i++) {\n\t\tgraph[models[i]] = {\n\t\t\t// http://jsperf.com/1-vs-infinity\n\t\t\t// micro-opt, but this is simple.\n\t\t\tdistance: -1,\n\t\t\tparent: null\n\t\t};\n\t}\n\n\treturn graph;\n}\n\n// https://en.wikipedia.org/wiki/Breadth-first_search\nfunction deriveBFS(fromModel) {\n\tconst graph = buildGraph();\n\tconst queue = [fromModel]; // Unshift -> queue -> pop\n\n\tgraph[fromModel].distance = 0;\n\n\twhile (queue.length) {\n\t\tconst current = queue.pop();\n\t\tconst adjacents = Object.keys(conversions[current]);\n\n\t\tfor (let len = adjacents.length, i = 0; i < len; i++) {\n\t\t\tconst adjacent = adjacents[i];\n\t\t\tconst node = graph[adjacent];\n\n\t\t\tif (node.distance === -1) {\n\t\t\t\tnode.distance = graph[current].distance + 1;\n\t\t\t\tnode.parent = current;\n\t\t\t\tqueue.unshift(adjacent);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn graph;\n}\n\nfunction link(from, to) {\n\treturn function (args) {\n\t\treturn to(from(args));\n\t};\n}\n\nfunction wrapConversion(toModel, graph) {\n\tconst path = [graph[toModel].parent, toModel];\n\tlet fn = conversions[graph[toModel].parent][toModel];\n\n\tlet cur = graph[toModel].parent;\n\twhile (graph[cur].parent) {\n\t\tpath.unshift(graph[cur].parent);\n\t\tfn = link(conversions[graph[cur].parent][cur], fn);\n\t\tcur = graph[cur].parent;\n\t}\n\n\tfn.conversion = path;\n\treturn fn;\n}\n\nmodule.exports = function (fromModel) {\n\tconst graph = deriveBFS(fromModel);\n\tconst conversion = {};\n\n\tconst models = Object.keys(graph);\n\tfor (let len = models.length, i = 0; i < len; i++) {\n\t\tconst toModel = models[i];\n\t\tconst node = graph[toModel];\n\n\t\tif (node.parent === null) {\n\t\t\t// No possible conversion, or this node is the source model.\n\t\t\tcontinue;\n\t\t}\n\n\t\tconversion[toModel] = wrapConversion(toModel, graph);\n\t}\n\n\treturn conversion;\n};\n\n","'use strict'\r\n\r\nmodule.exports = {\r\n\t\"aliceblue\": [240, 248, 255],\r\n\t\"antiquewhite\": [250, 235, 215],\r\n\t\"aqua\": [0, 255, 255],\r\n\t\"aquamarine\": [127, 255, 212],\r\n\t\"azure\": [240, 255, 255],\r\n\t\"beige\": [245, 245, 220],\r\n\t\"bisque\": [255, 228, 196],\r\n\t\"black\": [0, 0, 0],\r\n\t\"blanchedalmond\": [255, 235, 205],\r\n\t\"blue\": [0, 0, 255],\r\n\t\"blueviolet\": [138, 43, 226],\r\n\t\"brown\": [165, 42, 42],\r\n\t\"burlywood\": [222, 184, 135],\r\n\t\"cadetblue\": [95, 158, 160],\r\n\t\"chartreuse\": [127, 255, 0],\r\n\t\"chocolate\": [210, 105, 30],\r\n\t\"coral\": [255, 127, 80],\r\n\t\"cornflowerblue\": [100, 149, 237],\r\n\t\"cornsilk\": [255, 248, 220],\r\n\t\"crimson\": [220, 20, 60],\r\n\t\"cyan\": [0, 255, 255],\r\n\t\"darkblue\": [0, 0, 139],\r\n\t\"darkcyan\": [0, 139, 139],\r\n\t\"darkgoldenrod\": [184, 134, 11],\r\n\t\"darkgray\": [169, 169, 169],\r\n\t\"darkgreen\": [0, 100, 0],\r\n\t\"darkgrey\": [169, 169, 169],\r\n\t\"darkkhaki\": [189, 183, 107],\r\n\t\"darkmagenta\": [139, 0, 139],\r\n\t\"darkolivegreen\": [85, 107, 47],\r\n\t\"darkorange\": [255, 140, 0],\r\n\t\"darkorchid\": [153, 50, 204],\r\n\t\"darkred\": [139, 0, 0],\r\n\t\"darksalmon\": [233, 150, 122],\r\n\t\"darkseagreen\": [143, 188, 143],\r\n\t\"darkslateblue\": [72, 61, 139],\r\n\t\"darkslategray\": [47, 79, 79],\r\n\t\"darkslategrey\": [47, 79, 79],\r\n\t\"darkturquoise\": [0, 206, 209],\r\n\t\"darkviolet\": [148, 0, 211],\r\n\t\"deeppink\": [255, 20, 147],\r\n\t\"deepskyblue\": [0, 191, 255],\r\n\t\"dimgray\": [105, 105, 105],\r\n\t\"dimgrey\": [105, 105, 105],\r\n\t\"dodgerblue\": [30, 144, 255],\r\n\t\"firebrick\": [178, 34, 34],\r\n\t\"floralwhite\": [255, 250, 240],\r\n\t\"forestgreen\": [34, 139, 34],\r\n\t\"fuchsia\": [255, 0, 255],\r\n\t\"gainsboro\": [220, 220, 220],\r\n\t\"ghostwhite\": [248, 248, 255],\r\n\t\"gold\": [255, 215, 0],\r\n\t\"goldenrod\": [218, 165, 32],\r\n\t\"gray\": [128, 128, 128],\r\n\t\"green\": [0, 128, 0],\r\n\t\"greenyellow\": [173, 255, 47],\r\n\t\"grey\": [128, 128, 128],\r\n\t\"honeydew\": [240, 255, 240],\r\n\t\"hotpink\": [255, 105, 180],\r\n\t\"indianred\": [205, 92, 92],\r\n\t\"indigo\": [75, 0, 130],\r\n\t\"ivory\": [255, 255, 240],\r\n\t\"khaki\": [240, 230, 140],\r\n\t\"lavender\": [230, 230, 250],\r\n\t\"lavenderblush\": [255, 240, 245],\r\n\t\"lawngreen\": [124, 252, 0],\r\n\t\"lemonchiffon\": [255, 250, 205],\r\n\t\"lightblue\": [173, 216, 230],\r\n\t\"lightcoral\": [240, 128, 128],\r\n\t\"lightcyan\": [224, 255, 255],\r\n\t\"lightgoldenrodyellow\": [250, 250, 210],\r\n\t\"lightgray\": [211, 211, 211],\r\n\t\"lightgreen\": [144, 238, 144],\r\n\t\"lightgrey\": [211, 211, 211],\r\n\t\"lightpink\": [255, 182, 193],\r\n\t\"lightsalmon\": [255, 160, 122],\r\n\t\"lightseagreen\": [32, 178, 170],\r\n\t\"lightskyblue\": [135, 206, 250],\r\n\t\"lightslategray\": [119, 136, 153],\r\n\t\"lightslategrey\": [119, 136, 153],\r\n\t\"lightsteelblue\": [176, 196, 222],\r\n\t\"lightyellow\": [255, 255, 224],\r\n\t\"lime\": [0, 255, 0],\r\n\t\"limegreen\": [50, 205, 50],\r\n\t\"linen\": [250, 240, 230],\r\n\t\"magenta\": [255, 0, 255],\r\n\t\"maroon\": [128, 0, 0],\r\n\t\"mediumaquamarine\": [102, 205, 170],\r\n\t\"mediumblue\": [0, 0, 205],\r\n\t\"mediumorchid\": [186, 85, 211],\r\n\t\"mediumpurple\": [147, 112, 219],\r\n\t\"mediumseagreen\": [60, 179, 113],\r\n\t\"mediumslateblue\": [123, 104, 238],\r\n\t\"mediumspringgreen\": [0, 250, 154],\r\n\t\"mediumturquoise\": [72, 209, 204],\r\n\t\"mediumvioletred\": [199, 21, 133],\r\n\t\"midnightblue\": [25, 25, 112],\r\n\t\"mintcream\": [245, 255, 250],\r\n\t\"mistyrose\": [255, 228, 225],\r\n\t\"moccasin\": [255, 228, 181],\r\n\t\"navajowhite\": [255, 222, 173],\r\n\t\"navy\": [0, 0, 128],\r\n\t\"oldlace\": [253, 245, 230],\r\n\t\"olive\": [128, 128, 0],\r\n\t\"olivedrab\": [107, 142, 35],\r\n\t\"orange\": [255, 165, 0],\r\n\t\"orangered\": [255, 69, 0],\r\n\t\"orchid\": [218, 112, 214],\r\n\t\"palegoldenrod\": [238, 232, 170],\r\n\t\"palegreen\": [152, 251, 152],\r\n\t\"paleturquoise\": [175, 238, 238],\r\n\t\"palevioletred\": [219, 112, 147],\r\n\t\"papayawhip\": [255, 239, 213],\r\n\t\"peachpuff\": [255, 218, 185],\r\n\t\"peru\": [205, 133, 63],\r\n\t\"pink\": [255, 192, 203],\r\n\t\"plum\": [221, 160, 221],\r\n\t\"powderblue\": [176, 224, 230],\r\n\t\"purple\": [128, 0, 128],\r\n\t\"rebeccapurple\": [102, 51, 153],\r\n\t\"red\": [255, 0, 0],\r\n\t\"rosybrown\": [188, 143, 143],\r\n\t\"royalblue\": [65, 105, 225],\r\n\t\"saddlebrown\": [139, 69, 19],\r\n\t\"salmon\": [250, 128, 114],\r\n\t\"sandybrown\": [244, 164, 96],\r\n\t\"seagreen\": [46, 139, 87],\r\n\t\"seashell\": [255, 245, 238],\r\n\t\"sienna\": [160, 82, 45],\r\n\t\"silver\": [192, 192, 192],\r\n\t\"skyblue\": [135, 206, 235],\r\n\t\"slateblue\": [106, 90, 205],\r\n\t\"slategray\": [112, 128, 144],\r\n\t\"slategrey\": [112, 128, 144],\r\n\t\"snow\": [255, 250, 250],\r\n\t\"springgreen\": [0, 255, 127],\r\n\t\"steelblue\": [70, 130, 180],\r\n\t\"tan\": [210, 180, 140],\r\n\t\"teal\": [0, 128, 128],\r\n\t\"thistle\": [216, 191, 216],\r\n\t\"tomato\": [255, 99, 71],\r\n\t\"turquoise\": [64, 224, 208],\r\n\t\"violet\": [238, 130, 238],\r\n\t\"wheat\": [245, 222, 179],\r\n\t\"white\": [255, 255, 255],\r\n\t\"whitesmoke\": [245, 245, 245],\r\n\t\"yellow\": [255, 255, 0],\r\n\t\"yellowgreen\": [154, 205, 50]\r\n};\r\n","'use strict';\nmodule.exports = {\n\tstdout: false,\n\tstderr: false\n};\n","module.exports = function(module) {\n\tif (!module.webpackPolyfill) {\n\t\tmodule.deprecate = function() {};\n\t\tmodule.paths = [];\n\t\t// module.parent = undefined by default\n\t\tif (!module.children) module.children = [];\n\t\tObject.defineProperty(module, \"loaded\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.l;\n\t\t\t}\n\t\t});\n\t\tObject.defineProperty(module, \"id\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.i;\n\t\t\t}\n\t\t});\n\t\tmodule.webpackPolyfill = 1;\n\t}\n\treturn module;\n};\n"],"sourceRoot":""} -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/mixed-dep/webpack.config.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 2 | const OmitJSforCSSPlugin = require('../../../../src/index.js'); 3 | const path = require('path'); 4 | 5 | module.exports = { 6 | entry: { 7 | d: path.join(__dirname, '../shared/mixed.js') 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.join(__dirname, '/dir') 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | use: [ 18 | MiniCssExtractPlugin.loader, 19 | 'css-loader' 20 | ] 21 | } 22 | ] 23 | }, 24 | mode : 'development', 25 | plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()], 26 | stats: 'none', 27 | devtool: 'source-map' 28 | }; 29 | -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/shared/colorful.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk'); 2 | chalk.green('color it green'); -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/shared/common.js: -------------------------------------------------------------------------------- 1 | const one = require('./one.js'); 2 | 3 | module.exports = function(){ 4 | return one + 2; 5 | }; -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/shared/mixed.js: -------------------------------------------------------------------------------- 1 | require('./colorful.js'); 2 | require('./styles.js'); 3 | const one = require('./one.js'); -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/shared/one.css: -------------------------------------------------------------------------------- 1 | .one { color : red; } -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/shared/one.js: -------------------------------------------------------------------------------- 1 | module.exports = function (){ 2 | return 1; 3 | }; -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/shared/styles.js: -------------------------------------------------------------------------------- 1 | require('./one.css'); 2 | require('./two.css'); -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/shared/three.css: -------------------------------------------------------------------------------- 1 | .three { color : green; } -------------------------------------------------------------------------------- /__tests__/fixtures/should-not-omit/shared/two.css: -------------------------------------------------------------------------------- 1 | .two { color : blue; } -------------------------------------------------------------------------------- /__tests__/js-file-entry.test.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const path = require('path'); 3 | const rimraf = require('rimraf'); 4 | const options = require('./fixtures/js-file-entry/webpack.config.js'); 5 | const optionsLess = require('./fixtures/js-file-entry/webpack.config.less.js'); 6 | const optionsSass = require('./fixtures/js-file-entry/webpack.config.sass.js'); 7 | const fileShouldNotExist = require('./utils/file-should-not-exist.js'); 8 | const chunkShouldNotContainFile = require('./utils/chunk-should-not-contain-file.js'); 9 | const dirPath = path.join(__dirname, './fixtures/js-file-entry/dir'); 10 | 11 | describe('JS file with CSS Dependencies as Entry', () => { 12 | beforeEach(done => { 13 | rimraf(dirPath, () => { 14 | done(); 15 | }); 16 | }); 17 | 18 | it('JS entry file should not exist', done => { 19 | webpack(options, (err, stats) => { 20 | fileShouldNotExist(dirPath, '/b.js'); 21 | chunkShouldNotContainFile(stats, 'b', 'b.js'); 22 | done(); 23 | }); 24 | }); 25 | 26 | it('JS entry source map should not exist', done => { 27 | const optionSourceMap = Object.assign({}, options); 28 | optionSourceMap.devtool = 'source-map'; 29 | 30 | webpack(optionSourceMap, (err, stats) => { 31 | fileShouldNotExist(dirPath, '/b.js.map'); 32 | chunkShouldNotContainFile(stats, 'b', 'b.js.map'); 33 | done(); 34 | }); 35 | }); 36 | 37 | it('JS entry file should not exist w/ less', done => { 38 | webpack(optionsLess, (err, stats) => { 39 | fileShouldNotExist(dirPath, '/l.js'); 40 | chunkShouldNotContainFile(stats, 'l', 'l.js'); 41 | done(); 42 | }); 43 | }); 44 | 45 | it('JS entry source map should not exist w/ less', done => { 46 | const optionSourceMap = Object.assign({}, optionsLess); 47 | optionSourceMap.devtool = 'source-map'; 48 | 49 | webpack(optionSourceMap, (err, stats) => { 50 | fileShouldNotExist(dirPath, '/l.js.map'); 51 | chunkShouldNotContainFile(stats, 'l', 'l.js.map'); 52 | done(); 53 | }); 54 | }); 55 | 56 | it('JS entry file should not exist w/ sass', done => { 57 | webpack(optionsSass, (err, stats) => { 58 | fileShouldNotExist(dirPath, '/s.js'); 59 | chunkShouldNotContainFile(stats, 's', 's.js'); 60 | done(); 61 | }); 62 | }); 63 | 64 | it('JS entry source map should not exist w/ sass', done => { 65 | const optionSourceMap = Object.assign({}, optionsSass); 66 | optionSourceMap.devtool = 'source-map'; 67 | 68 | webpack(optionSourceMap, (err, stats) => { 69 | fileShouldNotExist(dirPath, '/s.js.map'); 70 | chunkShouldNotContainFile(stats, 's', 's.js.map'); 71 | done(); 72 | }); 73 | }); 74 | }); 75 | -------------------------------------------------------------------------------- /__tests__/options.test.js: -------------------------------------------------------------------------------- 1 | const rimraf = require('rimraf'); 2 | const path = require('path'); 3 | const webpack = require('webpack'); 4 | const OmitJSforCSSPlugin = require('../src/index.js'); 5 | const fileShouldExist = require('./utils/file-should-exist.js'); 6 | const fileShouldNotExist = require('./utils/file-should-not-exist.js'); 7 | const chunkShouldContainFile = require('./utils/chunk-should-contain-file.js'); 8 | const previewOptions = require('./fixtures/options/preview/webpack.config.js'); 9 | const previewDirPath = path.join(__dirname, '/fixtures/options/preview/dir'); 10 | const verboseOptions = require('./fixtures/options/verbose/webpack.config.js'); 11 | const verboseDirPath = path.join(__dirname, '/fixtures/options/verbose/dir'); 12 | 13 | describe('Options', () => { 14 | describe('Argument', () => { 15 | it('should throw if an invalid argument is passed', done => { 16 | const errorMsg = 'OmitJSforCSSPlugin only takes an options "object" as an argument'; 17 | expect(() => { 18 | new OmitJSforCSSPlugin(5); 19 | }).toThrow(errorMsg); 20 | expect(() => { 21 | new OmitJSforCSSPlugin('verbose'); 22 | }).toThrow(errorMsg); 23 | expect(() => { 24 | new OmitJSforCSSPlugin(null); 25 | }).toThrow(errorMsg); 26 | expect(() => { 27 | new OmitJSforCSSPlugin([]); 28 | }).toThrow(errorMsg); 29 | done(); 30 | }); 31 | 32 | it('should not throw if a correct argument is passed', done => { 33 | expect(() => { 34 | new OmitJSforCSSPlugin({}); 35 | }).not.toThrow(); 36 | done(); 37 | }); 38 | }); 39 | 40 | describe('Preview', () => { 41 | beforeEach(done => { 42 | jest.clearAllMocks(); 43 | rimraf(previewDirPath, () => { 44 | done(); 45 | }); 46 | }); 47 | 48 | afterAll(() => { 49 | console.log.mockRestore(); 50 | }); 51 | 52 | it('should display the files that would be omitted', done => { 53 | console.log = jest.fn(); 54 | 55 | webpack(previewOptions, () => { 56 | 57 | expect(console.log).toHaveBeenNthCalledWith(1, 'PREVIEW File to be omitted for b : b.js'); 58 | expect(console.log).toHaveBeenNthCalledWith(2, 'PREVIEW File to be omitted for b : b.js.map'); 59 | 60 | done(); 61 | }); 62 | }); 63 | 64 | it('should not omit files', done => { 65 | webpack(previewOptions, (err, stats) => { 66 | fileShouldExist(previewDirPath, 'b.js'); 67 | chunkShouldContainFile(stats, 'b', 'b.js'); 68 | fileShouldExist(previewDirPath, 'b.js.map'); 69 | chunkShouldContainFile(stats, 'b', 'b.js.map'); 70 | done(); 71 | }); 72 | }); 73 | }); 74 | 75 | describe('Verbose', () => { 76 | beforeEach(done => { 77 | jest.clearAllMocks(); 78 | rimraf(verboseDirPath, () => { 79 | done(); 80 | }); 81 | }); 82 | 83 | afterAll(() => { 84 | console.log.mockRestore(); 85 | }); 86 | 87 | it('should display the files that are omitted to console', done => { 88 | console.log = jest.fn(); 89 | 90 | webpack(verboseOptions, () => { 91 | expect(console.log).toHaveBeenNthCalledWith(1, 'File omitted for b : b.js') 92 | expect(console.log).toHaveBeenNthCalledWith(2, 'File omitted for b : b.js.map') 93 | 94 | done(); 95 | }); 96 | }); 97 | }); 98 | 99 | }); 100 | -------------------------------------------------------------------------------- /__tests__/should-not-omit.test.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const path = require('path'); 3 | const rimraf = require('rimraf'); 4 | const fileShouldExist = require('./utils/file-should-exist.js'); 5 | const chunkShouldContainFile = require('./utils/chunk-should-contain-file.js'); 6 | // Internal 7 | const internalOptions = require('./fixtures/should-not-omit/internal-dep/webpack.config.js'); 8 | const internalDirPath = path.join(__dirname, './fixtures/should-not-omit/internal-dep/dir'); 9 | // External 10 | const externalOptions = require('./fixtures/should-not-omit/external-dep/webpack.config.js'); 11 | const externalOptionsArr = require('./fixtures/should-not-omit/external-dep/webpack.config.arr.js'); 12 | const externalDirPath = path.join(__dirname, '/fixtures/should-not-omit/external-dep/dir'); 13 | // External Internal 14 | const extInOptions = require('./fixtures/should-not-omit/external-internal/webpack.config.js'); 15 | const extInDirPath = path.join(__dirname, '/fixtures/should-not-omit/external-internal/dir'); 16 | const extInArrOptions = require('./fixtures/should-not-omit/external-internal/webpack.config.arr.js'); 17 | // Mixed 18 | const mixedOptions = require('./fixtures/should-not-omit/mixed-dep/webpack.config.js'); 19 | const mixedDirPath = path.join(__dirname, '/fixtures/should-not-omit/mixed-dep/dir'); 20 | 21 | describe("JS Dependencies that shouldn't be omitted", () => { 22 | describe('Internal', () => { 23 | beforeEach(done => { 24 | rimraf(internalDirPath, () => { 25 | done(); 26 | }); 27 | }); 28 | 29 | it('should not omit JS with internal deps', done => { 30 | webpack(internalOptions, (err, stats) => { 31 | fileShouldExist(internalDirPath, '/b.js'); 32 | chunkShouldContainFile(stats, 'b', 'b.js'); 33 | fileShouldExist(internalDirPath, '/b.js.map'); 34 | chunkShouldContainFile(stats, 'b', 'b.js.map'); 35 | done(); 36 | }); 37 | }); 38 | }); 39 | 40 | describe('External', () => { 41 | beforeEach(done => { 42 | rimraf(externalDirPath, () => { 43 | done(); 44 | }); 45 | }); 46 | 47 | it('should not omit JS with external dependencies', done => { 48 | webpack(externalOptions, (err, stats) => { 49 | fileShouldExist(externalDirPath, '/c.js'); 50 | chunkShouldContainFile(stats, 'c', 'c.js'); 51 | fileShouldExist(externalDirPath, '/c.js.map'); 52 | chunkShouldContainFile(stats, 'c', 'c.js.map'); 53 | done(); 54 | }); 55 | }); 56 | 57 | it('should not omit JS with an array of external dependencies', done => { 58 | webpack(externalOptionsArr, (err, stats) => { 59 | fileShouldExist(externalDirPath, '/e.js'); 60 | chunkShouldContainFile(stats, 'e', 'e.js'); 61 | fileShouldExist(externalDirPath, '/e.js.map'); 62 | chunkShouldContainFile(stats, 'e', 'e.js.map'); 63 | done(); 64 | }); 65 | }); 66 | }); 67 | 68 | describe('External Internal', () => { 69 | beforeEach(done => { 70 | rimraf(extInDirPath, () => { 71 | done(); 72 | }); 73 | }); 74 | 75 | it('should not omit JS with external and internal dependencies', done => { 76 | webpack(extInOptions, (err, stats) => { 77 | fileShouldExist(extInDirPath, '/f.js'); 78 | chunkShouldContainFile(stats, 'f', 'f.js'); 79 | fileShouldExist(extInDirPath, '/f.js.map'); 80 | chunkShouldContainFile(stats, 'f', 'f.js.map'); 81 | fileShouldExist(extInDirPath, '/f.css'); 82 | chunkShouldContainFile(stats, 'f', 'f.css'); 83 | fileShouldExist(extInDirPath, '/f.css.map'); 84 | chunkShouldContainFile(stats, 'f', 'f.css.map'); 85 | done(); 86 | }); 87 | }); 88 | 89 | it('should not omit JS with external and internal dependencies when entry is array', done => { 90 | webpack(extInArrOptions, (err, stats) => { 91 | fileShouldExist(extInDirPath, '/j.js'); 92 | chunkShouldContainFile(stats, 'j', 'j.js'); 93 | fileShouldExist(extInDirPath, '/j.js.map'); 94 | chunkShouldContainFile(stats, 'j', 'j.js.map'); 95 | fileShouldExist(extInDirPath, '/j.css'); 96 | chunkShouldContainFile(stats, 'j', 'j.css'); 97 | fileShouldExist(extInDirPath, '/j.css.map'); 98 | chunkShouldContainFile(stats, 'j', 'j.css.map'); 99 | done(); 100 | }); 101 | }); 102 | }); 103 | 104 | describe('Mixed', () => { 105 | beforeEach(done => { 106 | rimraf(mixedDirPath, () => { 107 | done(); 108 | }); 109 | }); 110 | 111 | it('should not omit JS with mixed dependencies', done => { 112 | webpack(mixedOptions, (err, stats) => { 113 | fileShouldExist(mixedDirPath, '/d.js'); 114 | chunkShouldContainFile(stats, 'd', 'd.js'); 115 | fileShouldExist(mixedDirPath, '/d.js.map'); 116 | chunkShouldContainFile(stats, 'd', 'd.js.map'); 117 | fileShouldExist(mixedDirPath, '/d.css'); 118 | chunkShouldContainFile(stats, 'd', 'd.css'); 119 | fileShouldExist(mixedDirPath, '/d.css.map'); 120 | chunkShouldContainFile(stats, 'd', 'd.css.map'); 121 | done(); 122 | }); 123 | }); 124 | }); 125 | }); 126 | -------------------------------------------------------------------------------- /__tests__/utils/chunk-should-contain-file.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param stats {String} The webpack compilation stats object 3 | * @param chunkName {String} The name of a chunk 4 | * @param fileName {String} The name of a file which should be contained in the chunk 5 | */ 6 | module.exports = function(stats, chunkName, fileName) { 7 | const chunks = stats.compilation.namedChunks; 8 | expect(typeof chunkName).toEqual('string'); 9 | const chunk = chunks.get(chunkName); 10 | expect(typeof chunk).toEqual('object'); 11 | expect(typeof fileName).toEqual('string'); 12 | expect(chunk.files).toContain(fileName); 13 | } 14 | -------------------------------------------------------------------------------- /__tests__/utils/chunk-should-not-contain-file.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param stats {String} The webpack compilation stats object 3 | * @param chunkName {String} The name of a chunk 4 | * @param fileName {String} The name of a file which should not be contained in the chunk 5 | */ 6 | module.exports = function(stats, chunkName, fileName) { 7 | const chunks = stats.compilation.namedChunks; 8 | expect(typeof chunkName).toEqual('string'); 9 | const chunk = chunks.get(chunkName); 10 | expect(typeof chunk).toEqual('object'); 11 | expect(typeof fileName).toEqual('string'); 12 | expect(chunk.files).not.toContain(fileName); 13 | } 14 | -------------------------------------------------------------------------------- /__tests__/utils/file-should-exist.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const fs = require('fs'); 3 | /** 4 | * @param dirPath {String} The directory path 5 | * @param fileName {String} The filename 6 | */ 7 | module.exports = function(dirPath, fileName) { 8 | expect(typeof dirPath).toEqual('string'); 9 | expect(typeof fileName).toEqual('string'); 10 | const dirDirectoryExists = fs.existsSync(dirPath); 11 | const jsEntryFileExists = fs.existsSync(path.join(dirPath, fileName)); 12 | expect(dirDirectoryExists).toEqual(true); 13 | expect(jsEntryFileExists).toEqual(true); 14 | }; 15 | -------------------------------------------------------------------------------- /__tests__/utils/file-should-not-exist.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | /** 4 | * @param dirPath {String} The directory path 5 | * @param fileName {String} The filename 6 | */ 7 | module.exports = function(dirPath, fileName) { 8 | const dirDirectoryExists = fs.existsSync(dirPath); 9 | const jsEntryFileExists = fs.existsSync(path.join(dirPath, fileName)); 10 | expect(typeof dirPath).toEqual('string'); 11 | expect(typeof fileName).toEqual('string'); 12 | expect(dirDirectoryExists).toEqual(true); 13 | expect(jsEntryFileExists).toEqual(false); 14 | }; 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webpack-omit-js-for-css-plugin", 3 | "version": "3.2.0", 4 | "description": "This plugin will omit bundled JS files for dependencies that are exclusively CSS, which become obsolete once mini-css-extract-plugin extracts inlined CSS into its own .css file", 5 | "main": "src/index.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/jsilvax/webpack-omit-js-for-css-plugin.git" 12 | }, 13 | "homepage": "https://github.com/jsilvax/webpack-omit-js-for-css-plugin", 14 | "scripts": { 15 | "test": "jest", 16 | "watch:test": "jest --watch", 17 | "test:cover": "jest --coverage", 18 | "report-coverage": "cat ./coverage/lcov.info | coveralls", 19 | "prepush": "npm run test:cover", 20 | "release": "npm run test:cover && git tag $npm_package_version && git commit -am $npm_package_version && git push && git push --tags && npm publish" 21 | }, 22 | "keywords": [ 23 | "webpack", 24 | "plugin", 25 | "mini-css-extract-plugin", 26 | "omit-js-for-css-plugin", 27 | "omit js", 28 | "webpack omit", 29 | "css", 30 | "sass", 31 | "scss", 32 | "less" 33 | ], 34 | "author": "Jessica Silva", 35 | "license": "MIT", 36 | "peerDependencies": { 37 | "webpack": "^4.0.0" 38 | }, 39 | "devDependencies": { 40 | "coveralls": "^3.0.9", 41 | "css-loader": "^3.4.2", 42 | "husky": "^4.2.1", 43 | "jest": "^25.1.0", 44 | "less": "^3.0.4", 45 | "less-loader": "^5.0.0", 46 | "mini-css-extract-plugin": "^0.9.0", 47 | "node-sass": "^4.9.0", 48 | "preact": "^10.3.0", 49 | "rimraf": "^3.0.1", 50 | "sass-loader": "^8.0.2", 51 | "style-loader": "^1.1.3", 52 | "webpack": "^4.10.1", 53 | "webpack-cli": "^3.3.10" 54 | }, 55 | "dependencies": {}, 56 | "jest": { 57 | "verbose": true, 58 | "testRegex": "/__tests__/.*.test.js$" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * OmitJSforCSSPlugin 3 | * @description : This plugin will omit bundled JS files, for dependencies that are exclusively CSS which become obsolete once extract-text-plugin extracts inlined CSS into its own .css file 4 | */ 5 | 6 | /** 7 | * @param {Object} options - Configurable options 8 | * @constructor 9 | */ 10 | function OmitJSforCSSPlugin(options) { 11 | const defaults = { 12 | preview: false, // OPTIONAL - {Boolean} - A preview of the files that are to be omitted (Will not actually omit) 13 | verbose: false // OPTIONAL - {Boolean} - Whether it should display which files will be omitted 14 | }; 15 | 16 | if ((typeof options !== 'undefined' && (options === null || typeof options !== 'object')) || Array.isArray(options)) { 17 | throw new Error('OmitJSforCSSPlugin only takes an options "object" as an argument'); 18 | } 19 | 20 | this.options = Object.assign({}, defaults, options || {}); 21 | } 22 | 23 | /** 24 | * @function omitFiles 25 | * @param {String} filename - The omitted file name 26 | * @param {Object} chunk - The chunk containing the file to omit 27 | * @param {Object} compilation 28 | */ 29 | OmitJSforCSSPlugin.prototype.omitFiles = function (filename, chunk, compilation) { 30 | if (this.options.preview) { 31 | console.log(`PREVIEW File to be omitted for ${chunk.name} : ${filename}`); 32 | } else { 33 | this.options.verbose && console.log(`File omitted for ${chunk.name} : ${filename}`); 34 | chunk.files = chunk.files.filter(name => name !== filename); 35 | delete compilation.assets[filename]; 36 | } 37 | }; 38 | 39 | /** 40 | * @function findOmissibleFiles 41 | * @param {Object} compilation 42 | */ 43 | /** 44 | * @function findOmissibleFiles 45 | * @param {Object} compilation 46 | */ 47 | OmitJSforCSSPlugin.prototype.findOmissibleFiles = function (compilation) { 48 | // Every chunk / entry point 49 | compilation.chunks.forEach(chunk => { 50 | let resourceOrigin = {}; 51 | let assetTypeCount = { internal: 0, css: 0 }; 52 | 53 | if (chunk.entryModule) { 54 | resourceOrigin[chunk.entryModule.resource] = true; 55 | } 56 | 57 | // Each entry point will have its own dependencies, based on the files inner deps or the array deps in entry 58 | Array.from(chunk.modulesIterable, module => { 59 | module.dependencies.forEach(({ module }) => { 60 | if (module) { 61 | const { resource } = module; 62 | if (resource && !resourceOrigin[resource]) { 63 | /\.(css|less|scss|sass)$/i.test(resource) ? assetTypeCount.css++ : assetTypeCount.internal++; 64 | } 65 | } 66 | }); 67 | }); 68 | 69 | // Get the filenames that will be emitted, generated by the chunk, and omit JS if applicable 70 | chunk.files.forEach(filename => { 71 | // If all dependencies of this entry were CSS, then a JS version of this file will be created 72 | // This js file will be empty due to extract-text-webpack-plugin 73 | if (assetTypeCount.css > 0 && assetTypeCount.internal === 0 && (/\.(js)$/i.test(filename) || /\.(js).map$/i.test(filename))) { 74 | this.omitFiles(filename, chunk, compilation); 75 | } 76 | }); 77 | }); 78 | }; 79 | 80 | /** 81 | * Hook into the webpack compiler 82 | * @param {Object} compiler - The webpack compiler object 83 | */ 84 | OmitJSforCSSPlugin.prototype.apply = function (compiler) { 85 | compiler.hooks.emit.tap('OmitJSforCSSPlugin', (compilation) => { 86 | this.findOmissibleFiles(compilation); 87 | }); 88 | }; 89 | 90 | module.exports = OmitJSforCSSPlugin; 91 | --------------------------------------------------------------------------------