{"name":"val-loader","version":"1.1.1","description":"val loader module for webpack","license":"MIT","repository":{"type":"git","url":"git+https://github.com/webpack-contrib/val-loader.git"},"author":{"name":"Tobias Koppers @sokra"},"homepage":"https://github.com/webpack-contrib/val-loader","bugs":{"url":"https://github.com/webpack-contrib/val-loader/issues"},"main":"dist/cjs.js","engines":{"node":">= 6.9.0 || >= 8.9.0"},"scripts":{"start":"npm run build -- -w","build":"cross-env NODE_ENV=production babel src -d dist --ignore 'src/**/*.test.js' --copy-files","clean":"del-cli dist","commitlint":"commitlint","commitmsg":"commitlint -e $GIT_PARAMS","lint":"eslint --cache src test","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}","lint-staged":"lint-staged","prebuild":"npm run clean","prepublish":"npm run build","release":"standard-version","release:ci":"conventional-github-releaser -p angular","release:validate":"commitlint --from=$(git describe --tags --abbrev=0) --to=$(git rev-parse HEAD)","security":"nsp check","test":"jest","test:watch":"jest --watch","test:coverage":"jest --collectCoverageFrom='src/**/*.js' --coverage","ci:lint":"npm run lint && npm run security","ci:test":"npm run test -- --runInBand","ci:coverage":"npm run test:coverage -- --runInBand","defaults":"webpack-defaults","webpack-defaults":"webpack-defaults"},"files":["dist"],"keywords":["webpack"],"peerDependencies":{"webpack":"^2.0.0 || ^3.0.0 || ^4.0.0"},"dependencies":{"loader-utils":"^1.0.0","schema-utils":"^0.4.5"},"devDependencies":{"@commitlint/cli":"^6.1.3","@commitlint/config-angular":"^6.1.3","@webpack-contrib/eslint-config-webpack":"^2.0.4","babel-cli":"^6.0.0","babel-jest":"^20.0.0","babel-plugin-transform-object-rest-spread":"^6.0.0","babel-polyfill":"^6.0.0","babel-preset-env":"^1.0.0","conventional-github-releaser":"^2.0.2","cross-env":"^5.0.0","del":"^3.0.0","del-cli":"^1.0.0","eslint":"^4.0.0","eslint-config-webpack":"^1.0.0","eslint-plugin-import":"^2.0.0","eslint-plugin-prettier":"^2.6.0","husky":"^0.14.3","inspect-loader":"^1.0.0","jest":"^20.0.0","lint-staged":"^4.3.0","memory-fs":"^0.4.1","nsp":"^3.2.1","pre-commit":"^1.0.0","prettier":"^1.11.1","standard-version":"^4.0.0","webpack":"^3.11.0","webpack-defaults":"^2.1.4"},"pre-commit":"lint-staged","lint-staged":{"*.js":["eslint --fix","git add"]},"gitHead":"805f627596e58716cf83c6c9349e68666ff4c541","_id":"val-loader@1.1.1","_npmVersion":"6.1.0","_nodeVersion":"8.11.1","_npmUser":{"name":"evilebottnawi","email":"sheo13666q@gmail.com"},"dist":{"integrity":"sha512-JLqLXJWCVLXTxbUeHhLpWkgl3+X3U8Bl0vY7rTFZgFSbLJaEtAxuD2ixy/cM8w/gzC7sS3NE5IDSzClDt332sw==","shasum":"32ba8ed5c3607504134977251db2966499e15ef7","tarball":"http://registry-npm.ywwl.com/val-loader/download/val-loader-1.1.1.tgz","fileCount":6,"unpackedSize":13338,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbK39mCRA9TVsSAnZWagAAmLkP/163k/BNoNXbeWeCcTux\nfxs/LcFODfxfh35O+MMUcl2iaCg2DP1cTxAHForOBv88VZQu3DAgXuUCWWRn\n81HLRQXdrCSzskmywBbKsBjX/2CHVxYT6BGRA9EXx02CFwFnWEhcV4q/U2kz\nmJU2VPUp3EefP06mRaO1i0Rd7GkwBUfS2QZ85cWVO5cZCCwjhesO/nYXaJxh\nYfojefnNDTmt/98DItgZegavii2iidr67oKseV2UtoRF+uSslvngOcXv8/zs\njc91aBBskRxUFMm5RinTwl7BmzhTQP/XgU3FM9DhrZeBV7RCidgWtzo29cbl\neXrNXWz6FrBha/bUmMK4BfC+2XMKW4ILhkGYkHwi70A96SHjDVdZdJ7PykaV\ndgFvgo/BmAGER52zB+Fp70+aHSC5Di9PgKWmecHwY5m4wbfxX1GWBuUEg8jJ\njd+ZMBAw/J84+ajE1pOwmwVIrxwFDL7oNBP++Hpamemsh3Tz1QG0Ot23/kmR\nuB1NcZt4+SA6i1IfCrlLhFTNkt6tIlIDVG5U8AwYSAIRKRRgloD/+FwZFZoo\n1/yq7ZrNeWSRggCCV8T8i2Q8ySnUbkKLZirAo74VRTMtffIYOXcKbSEX8PYS\nEMzoRKe/4JsKb0cs5rw4A9g3Pk+iCRI0AoqrZj5DU8EytMHHarM3ODb0hYh2\n9Szi\r\n=0nqA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCg5IvP2Az8aQjXmY0JUQ1+JLbs8Ft6Uf/ZLQV1aFxJGQIhALIBkDV3rP4APQfwnHthUfmGar1Z2OwcbxgNfd/VID7q"}],"size":5162,"noattachment":false,"key":"/val-loader/-/val-loader-1.1.1.tgz"},"maintainers":[{"email":"bebraw@gmail.com","name":"bebraw"},{"email":"wiens.joshua@gmail.com","name":"d3viant0ne"},{"email":"eric@smarterspam.com","name":"ericclemmons"},{"email":"sheo13666q@gmail.com","name":"evilebottnawi"},{"email":"mail@johannesewald.de","name":"jhnns"},{"email":"j.tangelder@gmail.com","name":"jtangelder"},{"email":"michael.ciniawsky@gmail.com","name":"michael-ciniawsky"},{"email":"andrew@shellscape.org","name":"shellscape"},{"email":"tobias.koppers@googlemail.com","name":"sokra"},{"email":"sean.larkin@cuw.edu","name":"thelarkinn"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/val-loader_1.1.1_1529577316952_0.636671098560549"},"_hasShrinkwrap":false,"readme":"<div align=\"center\">\n  <a href=\"https://github.com/webpack/webpack\">\n    <img width=\"200\" height=\"200\" src=\"https://webpack.js.org/assets/icon-square-big.svg\">\n  </a>\n</div>\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![discussion][discussion]][discussion-url]\n[![size][size]][size-url]\n\n# val-loader\n\nA webpack loader which executes a given module, and returns the result of the\nexecution at build-time, when the module is required in the bundle. In this way,\nthe loader changes a module from code to a result.\n\nAnother way to view `val-loader`, is that it allows a user a way to make their\nown custom loader logic, without having to write a custom loader.\n\nThe target module is called with two arguments: `(options, loaderContext)`\n\n- `options`: The loader options (for instance provided in the webpack config. See the [example](#examples) below).\n- `loaderContext`: [The loader context](https://webpack.js.org/api/loaders/#the-loader-context).\n\n## Getting Started\n\nTo begin, you'll need to install `val-loader`:\n\n```console\nnpm install val-loader --save-dev\n```\n\n```console\nyarn add -D val-loader\n```\n\n```console\npnpm add -D val-loader\n```\n\nThen add the loader to your `webpack` config. For example:\n\n**target-file.js**\n\n```js\nmodule.exports = (options, loaderContext) => {\n  return { code: \"module.exports = 42;\" };\n};\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /target-file.js$/,\n        use: [\n          {\n            loader: `val-loader`,\n          },\n        ],\n      },\n    ],\n  },\n};\n```\n\n**src/entry.js**\n\n```js\nconst answer = require(\"target-file\");\n```\n\nAnd run `webpack` via your preferred method.\n\n## Options\n\n- **[`executableFile`](#executableFile)**\n\n### `executableFile`\n\nType:\n\n```ts\ntype executableFile = string;\n```\n\nDefault: `undefined`\n\nAllows to specify path to the executable file\n\n**data.json**\n\n```json\n{\n  \"years\": \"10\"\n}\n```\n\n**executable-file.js**\n\n```js\nmodule.exports = function yearsInMs(options, loaderContext, content) {\n  const { years } = JSON.parse(content);\n  const value = years * 365 * 24 * 60 * 60 * 1000;\n\n  return {\n    cacheable: true,\n    code: \"module.exports = \" + value,\n  };\n};\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(json)$/i,\n        rules: [\n          {\n            loader: \"val-loader\",\n            options: {\n              executableFile: path.resolve(\n                __dirname,\n                \"fixtures\",\n                \"executableFile.js\",\n              ),\n            },\n          },\n        ],\n      },\n      {\n        test: /\\.json$/i,\n        type: \"asset/resource\",\n      },\n    ],\n  },\n};\n```\n\n## Return Object Properties\n\nTargeted modules of this loader must export a `Function` that returns an object,\nor a `Promise` resolving an object (e.g. async function), containing a `code` property at a minimum, but can\ncontain any number of additional properties.\n\n### `code`\n\nType:\n\n```ts\ntype code = string | Buffer;\n```\n\nDefault: `undefined`\n_Required_\n\nCode passed along to webpack or the next loader that will replace the module.\n\n### `sourceMap`\n\nType:\n\n```ts\ntype sourceMap = object;\n```\n\nDefault: `undefined`\n\nA source map passed along to webpack or the next loader.\n\n### `ast`\n\nType:\n\n```ts\ntype ast = Array<object>;\n```\n\nDefault: `undefined`\n\nAn [Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree)\nthat will be passed to the next loader. Useful to speed up the build time if the\nnext loader uses the same AST.\n\n### `dependencies`\n\nType:\n\n```ts\ntype dependencies = Array<string>;\n```\n\nDefault: `[]`\n\nAn array of absolute, native paths to file dependencies that should be watched by webpack for changes.\n\nDependencies can also be added using [`loaderContext.addDependency(file: string)`](https://webpack.js.org/api/loaders/#thisadddependency).\n\n### `contextDependencies`\n\nType:\n\n```ts\ntype contextDependencies = Array<string>;\n```\n\nDefault: `[]`\n\nAn array of absolute, native paths to directory dependencies that should be watched by webpack for changes.\n\nContext dependencies can also be added using [`loaderContext.addContextDependency(directory: string)`](https://webpack.js.org/api/loaders/#thisaddcontextdependency).\n\n### `buildDependencies`\n\nType:\n\n```ts\ntype buildDependencies = Array<string>;\n```\n\nDefault: `[]`\n\nAn array of absolute, native paths to directory dependencies that should be watched by webpack for changes.\n\nBuild dependencies can also be added using `loaderContext.addBuildDependency(file: string)`.\n\n### `cacheable`\n\nType:\n\n```ts\ntype cacheable = boolean;\n```\n\nDefault: `false`\n\nIf `true`, specifies that the code can be re-used in watch mode if none of the\n`dependencies` have changed.\n\n## Examples\n\n### Simple\n\nIn this example the loader is configured to operator on a file name of\n`years-in-ms.js`, execute the code, and store the result in the bundle as the\nresult of the execution. This example passes `years` as an `option`, which\ncorresponds to the `years` parameter in the target module exported function:\n\n**years-in-ms.js**\n\n```js\nmodule.exports = function yearsInMs({ years }) {\n  const value = years * 365 * 24 * 60 * 60 * 1000;\n\n  // NOTE: this return value will replace the module in the bundle\n  return {\n    cacheable: true,\n    code: \"module.exports = \" + value,\n  };\n};\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: require.resolve(\"src/years-in-ms.js\"),\n        use: [\n          {\n            loader: \"val-loader\",\n            options: {\n              years: 10,\n            },\n          },\n        ],\n      },\n    ],\n  },\n};\n```\n\nIn the bundle, requiring the module then returns:\n\n```js\nimport tenYearsMs from \"years-in-ms\";\n\nconsole.log(tenYearsMs); // 315360000000\n```\n\n### Modernizr\n\nExample shows how to build [`modernizr`](https://www.npmjs.com/package/modernizr).\n\n**entry.js**\n\n```js\nimport modenizr from \"./modernizr.js\";\n```\n\n**modernizr.js**\n\n```js\nconst modernizr = require(\"modernizr\");\n\nmodule.exports = function (options) {\n  return new Promise(function (resolve) {\n    // It is impossible to throw an error because modernizr causes the process.exit(1)\n    modernizr.build(options, function (output) {\n      resolve({\n        cacheable: true,\n        code: `var modernizr; var hadGlobal = 'Modernizr' in window; var oldGlobal = window.Modernizr; ${output} modernizr = window.Modernizr; if (hadGlobal) { window.Modernizr = oldGlobal; } else { delete window.Modernizr; } export default modernizr;`,\n      });\n    });\n  });\n};\n```\n\n**webpack.config.js**\n\n```js\nconst path = require(\"path\");\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: path.resolve(__dirname, \"src\", \"modernizr.js\"),\n        use: [\n          {\n            loader: \"val-loader\",\n            options: {\n              minify: false,\n              options: [\"setClasses\"],\n              \"feature-detects\": [\n                \"test/css/flexbox\",\n                \"test/es6/promises\",\n                \"test/serviceworker\",\n              ],\n            },\n          },\n        ],\n      },\n    ],\n  },\n};\n```\n\n### Figlet\n\nExample shows how to build [`figlet`](https://www.npmjs.com/package/figlet).\n\n**entry.js**\n\n```js\nimport { default as figlet } from \"./figlet.js\";\n\nconsole.log(figlet);\n```\n\n**figlet.js**\n\n```js\nconst figlet = require(\"figlet\");\n\nfunction wrapOutput(output, config) {\n  let figletOutput = \"\";\n\n  if (config.textBefore) {\n    figletOutput += encodeURI(`${config.textBefore}\\n`);\n  }\n\n  output.split(\"\\n\").forEach((line) => {\n    figletOutput += encodeURI(`${line}\\n`);\n  });\n\n  if (config.textAfter) {\n    figletOutput += encodeURI(`${config.textAfter}\\n`);\n  }\n\n  return `module.exports = decodeURI(\"${figletOutput}\");`;\n}\n\nmodule.exports = function (options) {\n  const defaultConfig = {\n    fontOptions: {\n      font: \"ANSI Shadow\",\n      horizontalLayout: \"default\",\n      kerning: \"default\",\n      verticalLayout: \"default\",\n    },\n    text: \"FIGLET-LOADER\",\n    textAfter: null,\n    textBefore: null,\n  };\n\n  const config = Object.assign({}, defaultConfig, options);\n\n  return new Promise(function (resolve, reject) {\n    figlet.text(config.text, config.fontOptions, (error, output) => {\n      if (error) {\n        return reject(error);\n      }\n\n      resolve({\n        cacheable: true,\n        code: \"module.exports = \" + wrapOutput(output, config),\n      });\n    });\n  });\n};\n```\n\n**webpack.config.js**\n\n```js\nconst path = require(\"path\");\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: path.resolve(__dirname, \"src\", \"figlet.js\"),\n        use: [\n          {\n            loader: \"val-loader\",\n            options: {\n              text: \"FIGLET\",\n            },\n          },\n        ],\n      },\n    ],\n  },\n};\n```\n\n## Contributing\n\nPlease take a moment to read our contributing guidelines if you haven't yet done so.\n\n[CONTRIBUTING](./.github/CONTRIBUTING.md)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/val-loader.svg\n[npm-url]: https://npmjs.com/package/val-loader\n[node]: https://img.shields.io/node/v/val-loader.svg\n[node-url]: https://nodejs.org\n[tests]: https://github.com/webpack-contrib/val-loader/workflows/val-loader/badge.svg\n[tests-url]: https://github.com/webpack-contrib/val-loader/actions\n[cover]: https://codecov.io/gh/webpack-contrib/val-loader/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack-contrib/val-loader\n[discussion]: https://img.shields.io/github/discussions/webpack/webpack\n[discussion-url]: https://github.com/webpack/webpack/discussions\n[size]: https://packagephobia.now.sh/badge?p=val-loader\n[size-url]: https://packagephobia.now.sh/result?p=val-loader\n","publish_time":1529577317031,"_cnpm_publish_time":1529577317031,"dist-tags":{"latest":"6.0.0"}}