Skip to content

Instantly share code, notes, and snippets.

@phjardas
Last active May 21, 2018 10:46
Show Gist options
  • Save phjardas/4c7b26536c9d7c151a8913e7d1137df2 to your computer and use it in GitHub Desktop.
Save phjardas/4c7b26536c9d7c151a8913e7d1137df2 to your computer and use it in GitHub Desktop.
colors.js Webpack Test

colors.js webpack test

This is a little test to verify the bundleability of colors.js with Webpack. See Marak/colors.js#203 (comment) for details.

Broken

npm i colors@~1.2.0 && npm run build

While the output is correctly bundled in dist/index.js, the build (rightfully) emits the following warning:

WARNING in ./node_modules/colors/lib/extendStringPrototype.js
95:31-45 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/colors/lib/extendStringPrototype.js
 @ ./node_modules/colors/lib/index.js
 @ ./src/index.js

Fixed

npm i colors@~1.3.0 && npm run build

Builds the project without warnings.

require("colors");
{
"name": "colors-test",
"version": "1.0.0",
"scripts": {
"build":
"rm -rf dist && webpack --mode development --entry ./index.js --output dist/index.js"
},
"dependencies": {
"colors": "^1.2.5"
},
"devDependencies": {
"webpack": "^4.8.3",
"webpack-cli": "^2.1.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment