Skip to content

Commit fa5d6d8

Browse files
committed
init
0 parents  commit fa5d6d8

File tree

17 files changed

+9342
-0
lines changed

17 files changed

+9342
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitattributes

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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
cache/
3+
dist/

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"bracketSpacing": true
5+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) EGOIST <[email protected]> (https://egoist.sh)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all 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,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<img src="https://user-images.githubusercontent.com/8784712/51839289-d122a380-2343-11e9-90b8-bc2756c5dee9.png" alt="logo">
2+
3+
---
4+
5+
[![NPM version](https://badgen.net/npm/v/import-http)](https://npmjs.com/package/import-http) [![NPM downloads](https://badgen.net/npm/dm/import-http)](https://npmjs.com/package/import-http) [![CircleCI](https://badgen.net/circleci/github/egoist/import-http/master)](https://circleci.com/gh/egoist/import-http/tree/master) [![donate](https://badgen.net/badge/support%20me/donate/ff69b4)](https://patreon.com/egoist) [![chat](https://badgen.net/badge/chat%20on/discord/7289DA)](https://chat.egoist.sh)
6+
7+
**Please consider [donating](https://www.patreon.com/egoist) to this project's author, [EGOIST](#author), to show your ❤️ and support.**
8+
9+
## Introduction
10+
11+
- Imports source code URLs! Like `<script type="module">` and [Deno](https://github.com/denoland/deno) but implemented in webpack. Embracing the future :)
12+
13+
```js
14+
import template from 'https://unpkg.com/lodash/template'
15+
16+
console.log(template(`Hello <%= name %>`)({ name: 'EGOIST' }))
17+
```
18+
19+
Remote code is fetched and cached on first build, and never updated until
20+
you use the `reload` option. See more about [Caching](#caching).
21+
22+
- No more `node_modules` bloat, no dependency to install.
23+
24+
![image](https://unpkg.com/@egoist/media/projects/import-http/preview.svg)
25+
26+
## Install
27+
28+
```bash
29+
yarn add import-http --dev
30+
```
31+
32+
## Usage
33+
34+
In your `webpack.config.js`:
35+
36+
```js
37+
const ImportHttpPlugin = require('import-http')
38+
39+
module.exports = {
40+
plugins: [new ImportHttpPlugin()]
41+
}
42+
```
43+
44+
That's it, try following code:
45+
46+
```js
47+
import React from 'https://unpkg.com/react'
48+
import Vue from 'https://unpkg.com/vue'
49+
50+
console.log(React, Vue)
51+
```
52+
53+
Run webpack and it just works.
54+
55+
## Caching
56+
57+
Resources will be fetched at the very first build, then the response will be cached in `~/.import-http` dir. You can use the `reload` option to invalidate cache:
58+
59+
```js
60+
const ImportHttpPlugin = require('import-http')
61+
62+
module.exports = {
63+
plugins: [
64+
new ImportHttpPlugin({
65+
reload: process.env.RELOAD
66+
})
67+
]
68+
}
69+
```
70+
71+
Then run `RELOAD=true webpack` to update cache.
72+
73+
## Contributing
74+
75+
1. Fork it!
76+
2. Create your feature branch: `git checkout -b my-new-feature`
77+
3. Commit your changes: `git commit -am 'Add some feature'`
78+
4. Push to the branch: `git push origin my-new-feature`
79+
5. Submit a pull request :D
80+
81+
## Author
82+
83+
**import-http** © EGOIST, Released under the [MIT](./LICENSE) License.<br>
84+
Authored and maintained by EGOIST with help from contributors ([list](https://github.com/egoist/import-http/contributors)).
85+
86+
> [Website](https://egoist.sh) · GitHub [@EGOIST](https://github.com/egoist) · Twitter [@\_egoistlily](https://twitter.com/_egoistlily)

circle.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: circleci/node:latest
6+
branches:
7+
ignore:
8+
- gh-pages # list of branches to ignore
9+
- /release\/.*/ # or ignore regexes
10+
steps:
11+
- checkout
12+
- restore_cache:
13+
key: dependency-cache-{{ checksum "yarn.lock" }}
14+
- run:
15+
name: install dependences
16+
command: yarn
17+
- save_cache:
18+
key: dependency-cache-{{ checksum "yarn.lock" }}
19+
paths:
20+
- ./node_modules
21+
- run:
22+
name: test
23+
command: yarn test
24+
- run:
25+
name: release
26+
command: yarn semantic-release

example/foo.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default 'foo'
2+
3+
console.log('fooooo')

example/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import template from 'https://unpkg.com/lodash/template'
2+
3+
console.log(template(`Hello <%= name %>`)({name: 'EGOIST'}))

example/webpack.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const ImportHttpPlugin = require('..')
2+
3+
module.exports = {
4+
mode: 'development',
5+
devtool: false,
6+
entry: __dirname + '/index.js',
7+
output: {
8+
path: __dirname + '/dist',
9+
filename: 'main.js'
10+
},
11+
plugins: [
12+
new ImportHttpPlugin({
13+
reload: process.env.RELOAD
14+
})
15+
],
16+
stats: {
17+
colors: true,
18+
chunks: false,
19+
children: false,
20+
modules: false,
21+
hash: false,
22+
version: false,
23+
timings: false,
24+
builtAt: false
25+
}
26+
}

0 commit comments

Comments
 (0)