Skip to content
This repository was archived by the owner on Nov 5, 2019. It is now read-only.

Commit db97dce

Browse files
committed
Initial commit
0 parents  commit db97dce

File tree

6 files changed

+56
-0
lines changed

6 files changed

+56
-0
lines changed

.gitignore

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

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# script loader for webpack
2+
3+
## Usage
4+
5+
``` javascript
6+
require("script!./file.js");
7+
// => execute file.js once in global context
8+
```
9+
10+
Does nothing in node.js.
11+
12+
## License
13+
14+
MIT (http://www.opensource.org/licenses/mit-license.php)

addScript.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = function() {}

addScript.web.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra
4+
*/
5+
module.exports = function(src) {
6+
if (window.execScript)
7+
window.execScript(src);
8+
else
9+
eval.call(null, src);
10+
}

index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra
4+
*/
5+
var path = require("path");
6+
module.exports = function(content) {
7+
var loaderSign = this.request.indexOf("!");
8+
var rawJs = this.request.substr(loaderSign); // including leading "!"
9+
if(this.web)
10+
return "require(" + JSON.stringify(path.join(__dirname, "addScript")) + ")"+
11+
"(require(" +
12+
JSON.stringify("raw" + rawJs) + "))";
13+
return "";
14+
}

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "script-loader",
3+
"version": "0.1.1",
4+
"author": "Tobias Koppers @sokra",
5+
"description": "script loader module for webpack",
6+
"dependencies": {
7+
"raw-loader": "0.1.x"
8+
},
9+
"licenses": [
10+
{
11+
"type": "MIT",
12+
"url": "http://www.opensource.org/licenses/mit-license.php"
13+
}
14+
],
15+
"license": "MIT"
16+
}

0 commit comments

Comments
 (0)