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

Commit

Permalink
refactor: code (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Nov 21, 2019
1 parent 9b9cd8d commit a2f5faf
Show file tree
Hide file tree
Showing 9 changed files with 2,169 additions and 1,737 deletions.
3,711 changes: 2,003 additions & 1,708 deletions package-lock.json

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,34 @@
},
"dependencies": {
"loader-utils": "^1.2.3",
"schema-utils": "^2.0.0"
"schema-utils": "^2.5.0"
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/preset-env": "^7.7.1",
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"@webpack-contrib/defaults": "^5.0.2",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^24.8.0",
"babel-jest": "^24.9.0",
"commitlint-azure-pipelines-cli": "^1.0.2",
"cross-env": "^5.2.0",
"del": "^5.0.0",
"del-cli": "^2.0.0",
"eslint": "^6.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.18.0",
"husky": "^3.0.0",
"jest": "^24.8.0",
"jest-junit": "^6.4.0",
"lint-staged": "^9.2.0",
"memory-fs": "^0.4.1",
"cross-env": "^6.0.3",
"del": "^5.1.0",
"del-cli": "^3.0.0",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-import": "^2.18.2",
"husky": "^3.1.0",
"jest": "^24.9.0",
"jest-junit": "^9.0.0",
"lint-staged": "^9.4.3",
"memory-fs": "^0.5.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"standard-version": "^6.0.1",
"url-loader": "^2.0.1",
"webpack": "^4.36.1"
"prettier": "^1.19.1",
"standard-version": "^7.0.1",
"url-loader": "^2.2.0",
"webpack": "^4.41.2"
},
"keywords": [
"webpack"
Expand Down
8 changes: 3 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ export default function loader(content) {
this.emitFile(outputPath, content);
}

const esModules =
typeof options.esModules === 'boolean' && options.esModules === true;

// TODO revert to ES2015 Module export, when new CSS Pipeline is in place
return `${esModules ? 'export default' : 'module.exports ='} ${publicPath};`;
return `${
options.esModules ? 'export default' : 'module.exports ='
} ${publicPath};`;
}

export const raw = true;
3 changes: 3 additions & 0 deletions src/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
"instanceof": "RegExp"
}
]
},
"esModules": {
"type": "boolean"
}
},
"type": "object"
Expand Down
108 changes: 108 additions & 0 deletions test/__snapshots__/loader.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,113 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`loader should work with ModuleConcatenationPlugin 1`] = `
"/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = \\"\\";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
\\"use strict\\";
__webpack_require__.r(__webpack_exports__);
// CONCATENATED MODULE: ./file.png
/* harmony default export */ var file = (__webpack_require__.p + \\"9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\");
// CONCATENATED MODULE: ./fixture.js
/* eslint-disable */
/* harmony default export */ var fixture = __webpack_exports__[\\"default\\"] = (file);
/***/ })
/******/ ]);
//# sourceMappingURL=main.bundle.js.map"
`;

exports[`loader should works with \`url-loader\` when limit is less 1`] = `"module.exports = __webpack_public_path__ + \\"9c87cbf3ba33126ffd25ae7f2f6bbafb.png\\";"`;

exports[`loader should works with \`url-loader\` when limit is more 1`] = `"module.exports = \\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAAAXNSR0IArs4c6QAAGjNJREFUeAHtnQewFMXWx/uSxZxRUTGAAcyYnwpiJhgRFRCM6GeBZaklopaUWoUo9cwIqPhhAjGAWRQTRjAgijnnLOqnAgL3fv3rR+/r29uzO7t3e3Z2t0/V1uzM9Mx0n/nP6dPnnD4tRKDAgcCBwIFK4UCdq6JDhw5dZeHChRfKc4c2NDR0kNtWrnLhWE1woKGuru4X2dKX5fbym2666aU4rc4C1pAhQ/ZetmzZ7RJQG8W5QShTOxyQwKqXuPj3hhtueN7IkSPrc7W8uXny1FNPXa++vv55eXE783j4HziwnAMIoj3+T9Ibb7zxci6uNDNPSkk1VoJqdfNY+B84YHNAYuQyKYQ2s4+b+xlgyYJrSVHXxzwZ/gcORHCgjezZjos4pw630Cdlwa0kEjNA4/hqq60mLrzwQrXV5cK2tjggcSGmTp0qZs6caTe8s33A3DeBtLJ5gv8bbbRRAJXNlBrbb9asmejcORtDUm1q161bt8333XffDfr27buCzRYTWPa5sB84kJMDzZs3bybVpxV//fXXDQ8++OC1ZY+XsTIEYOVkXTgZlwP//PPP6gcddFBm4BeAFZdzoVxeDkh9bE3ZLSpjegBWXnaFAnE5IIFVJ7tFpasHYMXlWigXiwNS2W9NwQCsWOwKheJyoHXr1kqBD8CKy7FQriAOBGAVxK5QOC4HArDiciqUK4gDAVgFsSsUjsuBAKy4nArlCuJAAFZB7AqF43IgE90Q94JaKifdFGLRokVi6dKlolWrVqJNmzaiRYvAsjgYqFkuSe+8+OGHH8T333/f6LdgwQIFpsWLFwtCRmwCWNJWI1ZYYQWx1lpriXbt2jX6cSyQEDUDLOl5F19++aV4//331e/DDz8UgKdQQnrx++uvv8TPP/+s7mXeY9VVVxVbbLGF2HLLLdVvnXXWMU/XzP+qBhZgeu+998TLL78s5s2bJ/7++2/vL/b3338Xc+bMUT8etuaaa4qddtpJ7LHHHqJ9+/ben5+WB1QlsL799lvx0ksviVdeeUX89ttvZeX1L7/8Ip544gn1A1gAbNdddxVItmqmqgIW3dsjjzwi3nnnnZK8M3QprbBrRX7JkiVF3/vrr79WYb7333+/2G233cQhhxwiqrWrrApgzZ8/XwHqo48+Kuilr7zyyir8GgV83XXXVUo42xVXXFEp6DI6Mut+KP3oZnIGVCOln0EAOlwcvQ0d7YUXXlBStWvXrqJnz55igw02yHpWJR+oaGB99dVX4o477hCffPJJrHfASM5UrIvReWQ4rmjbtq36AcLtttsu82xA9+mnnyq9jkEC/wFRFDHqRB979dVXlQSTQXJilVVWiSpeUccrEljYlqZPny6efvppp0nAfAOYB7bddlul22yzzTYCYPgi7t2xY0f169Onj5BpChRoGDzkkqYMMvQA47DDDhPdu3cXLmnpq94+7ltxwOLrnjJlimD0lYvWW2890aNHD7Hzzjurri1XWV/nkJB77723+mGaYEDxzDPPqG7U9UxGrXfddZfqJgcNGiQ23nhjV7GKOFYxwEJ5vvPOO8WLL76Yk7FMWUMpZojv+urpPuX0cPHWW28pSXbooYfmvF+pTmI4RYrJCQfiueeeEzNmzIgcsaKrjRo1Shx55JFi//33L1UVEr1PRQAL88G4ceME2yhC+T3qqKME3Z1N2vzw+uuvi59++ilzGqU9acI1BFjo7lDgH3jgAacEQze7++67xQcffCBOOOGEskndYvmTemChe6CgR422MAcgCfbbbz/B5EqTGC0++eSTjcwPzO7eYYcdlERDkS8XofvJCZ+qq542bZqYNWuWU1988803xSWXXCJOO+00sckmm5SrugU/N9XAevjhh5WSHtUqhurHHHNMo9naK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I0x8EB7Hbkj7BJjor/tI+Z+xlzg/RXvS+D/eulfSYDNkDFrORAgQM2ByTgPraPmfsZEMnkEz9JUD1ongz/AwciOLBYLvrwUMQ5dTgDLPaktfl/pIhbkOuCcC5wQLq5rlqwYMFXuTjRCFgTJkz4ToLrMAmuL3NdFM7VJgckLuqlz/QWOa/zf/NxoBGwKCwnhM6S+tY28iZXyt+H8tA/+W4Szlc1Bxpk636VatLTsvs7Ti5acIX0jXIsJ+UNBJJJU9vKmKX2Oe8STgYOLOeABN2fcqb3t1kSy+aQnAoeJJbNlLAfyQE5WlzMybzAevbZZ5dKMfhX5J3CicCB5Rygi5Sx/soemhdYXCOnff8gA9bqAwcDB3JxQALrF7lEoOrh8upY+kboWtKA2k5Kr4xRVZ8L28ABGW69QE4U/lkO+JRiHxtYsK5v377N5chgDRm6u5L8tQzsrG0OSAzUSym1UM7h/FVKqoW1zY3Q+sCBwIHK5cD/A4bJawZvxvyKAAAAAElFTkSuQmCC\\""`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ exports[`validate options 6`] = `
* options.regExp should be a string.
* options.regExp should be an instance of RegExp."
`;

exports[`validate options 7`] = `
"Invalid options object. File Loader has been initialised using an options object that does not match the API schema.
- options.esModules should be a boolean."
`;
5 changes: 3 additions & 2 deletions test/helpers/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ const output = (config) => {
export default function(fixture, config, options) {
// webpack Config
config = {
mode: 'development',
mode: config.mode || 'development',
devtool: config.devtool || 'sourcemap',
context: path.resolve(__dirname, '..', 'fixtures'),
entry: `./${fixture}`,
output: output(config),
module: module(config),
plugins: plugins(config),
optimization: {
runtimeChunk: true,
minimize: false,
runtimeChunk: false,
},
};
// Compiler Options
Expand Down
18 changes: 18 additions & 0 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,22 @@ describe('loader', () => {

expect(source).toMatchSnapshot();
});

it('should work with ModuleConcatenationPlugin', async () => {
const config = {
mode: 'production',
loader: {
test: /(png|jpg|svg)/,
options: {
esModules: true,
},
},
};

const stats = await webpack('fixture.js', config);

expect(
stats.compilation.assets['main.bundle.js'].source()
).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,9 @@ it('validate options', () => {
expect(() => validate({ regExp: 'image\\.png' })).not.toThrow();
expect(() => validate({ regExp: true })).toThrowErrorMatchingSnapshot();

expect(() => validate({ esModules: true })).not.toThrow();
expect(() => validate({ esModules: false })).not.toThrow();
expect(() => validate({ esModules: 'true' })).toThrowErrorMatchingSnapshot();

expect(() => validate({ unknown: 'unknown' })).not.toThrow();
});

0 comments on commit a2f5faf

Please sign in to comment.