Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Import modules from URL instead of local node_modules

License

NotificationsYou must be signed in to change notification settings

egoist/import-http

Repository files navigation

logo


NPM versionNPM downloadsCircleCIdonatechat

Please considerdonating to this project's author,EGOIST, to show your ❤️ and support.

Introduction

  • Imports source code URLs! Like<script type="module"> andDeno but implemented as a webpack/Rollup plugin. Embracing the future :)

    importtemplatefrom'https://unpkg.com/lodash-es/template'console.log(template(`Hello <%= name %>`)({name:'EGOIST'}))

    Remote code is fetched and cached on first build, and never updated untilyou use thereload option. See more aboutCaching.

  • No morenode_modules bloat, no dependency to install.

image

Install

yarn add import-http --dev

Usage

Webpack

In yourwebpack.config.js:

constImportHttpWebpackPlugin=require('import-http/webpack')module.exports={plugins:[newImportHttpWebpackPlugin()]}

That's it, try following code:

importReactfrom'https://unpkg.com/react'importVuefrom'https://unpkg.com/vue'console.log(React,Vue)

Run webpack and it just works.

Rollup

In yourrollup.config.js:

exportdefault{plugins:[require('import-http/rollup')()]}

Caching

Resources will be fetched at the very first build, then the response will be cached in~/.cache/import-http dir. You can use thereload option to invalidate cache:

constImportHttpWebpackPlugin=require('import-http/webpack')module.exports={plugins:[newImportHttpWebpackPlugin({reload:process.env.RELOAD})]}

Then runRELOAD=true webpack to update cache.

Contributing

  1. Fork it!
  2. Create your feature branch:git checkout -b my-new-feature
  3. Commit your changes:git commit -am 'Add some feature'
  4. Push to the branch:git push origin my-new-feature
  5. Submit a pull request :D

Author

import-http © EGOIST, Released under theMIT License.
Authored and maintained by EGOIST with help from contributors (list).

Website · GitHub@EGOIST · Twitter@_egoistlily

About

Import modules from URL instead of local node_modules

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp