Skip to content

Commit 9146e9d

Browse files
committed
Initial commit.
0 parents  commit 9146e9d

File tree

12 files changed

+337
-0
lines changed

12 files changed

+337
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Changelog
2+
3+
## 0.1.0-dev
4+
* Initial version.

LICENSE.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Mark van Seventer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# custom-loader
2+
> Custom loader module for webpack.
3+
4+
## Install
5+
`$ npm install custom-loader`
6+
7+
## Usage
8+
```
9+
```
10+
11+
## Changelog
12+
See the [Changelog](./CHANGELOG.md) for a list of changes.
13+
14+
## License
15+
The MIT License (MIT)
16+
17+
Copyright (c) 2017 Mark van Seventer
18+
19+
Permission is hereby granted, free of charge, to any person obtaining a copy of
20+
this software and associated documentation files (the "Software"), to deal in
21+
the Software without restriction, including without limitation the rights to
22+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
23+
the Software, and to permit persons to whom the Software is furnished to do so,
24+
subject to the following conditions:
25+
26+
The above copyright notice and this permission notice shall be included in all
27+
copies or substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
31+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
32+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
33+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
34+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

index.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*!
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2017 Mark van Seventer
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
* the Software, and to permit persons to whom the Software is furnished to do so,
11+
* subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
24+
// @see https://webpack.js.org/development/how-to-write-a-loader/
25+
26+
// Strict mode.
27+
'use strict';
28+
29+
// Package modules.
30+
const loaderUtils = require('loader-utils');
31+
32+
// Exports.
33+
module.exports = function (source, map) {
34+
const context = this; // Extract.
35+
36+
// Flag as cacheable.
37+
context.cacheable();
38+
39+
// Extract config.
40+
const config = loaderUtils.getLoaderConfig(context, 'customLoader');
41+
if (typeof config.callback !== 'function') {
42+
throw new Error('Assertion failed: config.callback must be a function.');
43+
}
44+
45+
// Invoke custom loader.
46+
return config.callback.apply(context, source, map, context.callback);
47+
};
48+
49+
// Mark as raw.
50+
module.exports.raw = true;

main.js

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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+
/******/ // identity function for calling harmony imports with the correct context
37+
/******/ __webpack_require__.i = function(value) { return value; };
38+
39+
/******/ // define getter function for harmony exports
40+
/******/ __webpack_require__.d = function(exports, name, getter) {
41+
/******/ if(!__webpack_require__.o(exports, name)) {
42+
/******/ Object.defineProperty(exports, name, {
43+
/******/ configurable: false,
44+
/******/ enumerable: true,
45+
/******/ get: getter
46+
/******/ });
47+
/******/ }
48+
/******/ };
49+
50+
/******/ // getDefaultExport function for compatibility with non-harmony modules
51+
/******/ __webpack_require__.n = function(module) {
52+
/******/ var getter = module && module.__esModule ?
53+
/******/ function getDefault() { return module['default']; } :
54+
/******/ function getModuleExports() { return module; };
55+
/******/ __webpack_require__.d(getter, 'a', getter);
56+
/******/ return getter;
57+
/******/ };
58+
59+
/******/ // Object.prototype.hasOwnProperty.call
60+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
61+
62+
/******/ // __webpack_public_path__
63+
/******/ __webpack_require__.p = "";
64+
65+
/******/ // Load entry module and return exports
66+
/******/ return __webpack_require__(__webpack_require__.s = 0);
67+
/******/ })
68+
/************************************************************************/
69+
/******/ ([
70+
/* 0 */
71+
/***/ (function(module, exports, __webpack_require__) {
72+
73+
"use strict";
74+
/*!
75+
* The MIT License (MIT)
76+
*
77+
* Copyright (c) 2017 Mark van Seventer
78+
*
79+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
80+
* this software and associated documentation files (the "Software"), to deal in
81+
* the Software without restriction, including without limitation the rights to
82+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
83+
* the Software, and to permit persons to whom the Software is furnished to do so,
84+
* subject to the following conditions:
85+
*
86+
* The above copyright notice and this permission notice shall be included in all
87+
* copies or substantial portions of the Software.
88+
*
89+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
90+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
91+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
92+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
93+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
94+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
95+
*/
96+
97+
// Strict mode.
98+
99+
100+
// This file serves as the entry point for the test suite.
101+
102+
// Exports.
103+
module.exports = { foo: true };
104+
105+
106+
/***/ })
107+
/******/ ]);

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name" : "custom-loader",
3+
"version" : "0.1.0-dev",
4+
"description" : "Custom loader module for webpack.",
5+
"keywords" : [ "webpack", "loader", "module", "callback" ],
6+
"homepage" : "https://github.com/vseventer/custom-loader",
7+
"bugs" : "https://github.com/vseventer/custom-loader/issues",
8+
"license" : "MIT",
9+
"author" : "Mark van Seventer <mark@vseventer.com> (http://www.vseventer.com)",
10+
"repository" : "vseventer/custom-loader",
11+
"main" : "index.js",
12+
"scripts" : {
13+
"pretest" : "semistandard | snazzy",
14+
"test" : "mocha"
15+
},
16+
"dependencies": { "loader-utils": "0.2.x" },
17+
"devDependencies": {
18+
"chai" : "3.5.x",
19+
"mocha" : "3.2.x",
20+
"semistandard" : "9.2.x",
21+
"snazzy" : "6.0.x",
22+
"webpack" : "2.2.x"
23+
},
24+
"engines": {
25+
"node" : ">=6.x",
26+
"webpack" : ">=2.2.x"
27+
}
28+
}

test/fixtures/entry.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*!
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2017 Mark van Seventer
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
* the Software, and to permit persons to whom the Software is furnished to do so,
11+
* subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
24+
// Strict mode.
25+
'use strict';
26+
27+
// This file serves as the entry point for the test suite.
28+
29+
// Exports.
30+
module.exports = { foo: true };

0 commit comments

Comments
 (0)