Giter VIP home page Giter VIP logo

browserify-loader's Introduction

browserify-loader

A CommonJS Loader for browserify workflow.

What is browserify-loader

browserify-loader is another CommonJS loader for browserify workflow. With BL, You don’t need any tools like watchify, browserify-middleware to auto build and serve bundle *js in development env.

browserify-loader is similar with requirejs, but:

  • Follow module loading algorithm
  • get rid of wrapper code like define()
  • be compatible all npm package and all bower components witch support CommonJS. like underscore, backbone, jQuery and so on.

Getting started

Install

Download browserify-loader with npm:

$ npm install browserify-loader2

Put browserify-loader.min.js in your page:

<!DOCTYPE html>
<html>
<head>
  <title></title>
</head>
<body>
    <script main="./app.js" src="node_modules/browserify-loader2/out/browserify-loader.min.js"></script>
</body>
</html>

Then, browserify-loader will start to run for main file in your package.json file.

Options

  • main: the main entrance script like app.js in node app.js
  • defineName: The name of the define function. Not supported yet.
  • forceExt: Force loading files with valid extensions only, ignore files with invalid extenstion. Not supported yet.
  • forceDir: Force path which ends with / to be a directory module. Not supported yet.

Example

Look into example/index.html.

Tests

The module loader has test cases written in Qunit, open test/index.html.

browserify-loader's People

Contributors

island205 avatar zengfenfei avatar

Stargazers

Roman avatar Gabriel S. L avatar  avatar cx2889 avatar Ryan McQuen avatar Travis Taylor avatar James Michael DuPont avatar Ivan Koshkin avatar Andrey Izman avatar  avatar Munawwar avatar

Watchers

 avatar James Cloos avatar

Forkers

pnchen

browserify-loader's Issues

被加载js的路径解析不正确

a.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    
</body>

<script type="text/javascript" src="browserify-loader.js"></script>
</html>

package.json

{
    "main": "./a.js"
}

a.js

var bb = require("./b.js");
console.log(bb);

b.js

module.exports = 'It works from module.js.'

目录结构

---- a.html
---- a.js
---- b.js
---- package.json
---- browserify-loader.js

用浏览器访问的是 http://127.0.0.1:8080/a.html

出现的问题是:

GET http://b.js/ net::ERR_NAME_NOT_RESOLVED
GET http://b.js.js/ net::ERR_NAME_NOT_RESOLVED
GET http://b.js.json/ net::ERR_NAME_NOT_RESOLVED
GET http://127.0.0.1:8080/b.js/package.json 404 (Not Found)
GET http://127.0.0.1:8080/b.js/index.js 404 (Not Found)
GET http://127.0.0.1:8080/b.js/index.json 404 (Not Found)

明显a.js中的 require("./b.js"); 的 ./b.js 被认为是 http://b.js/
我认为 ./b.js 被解析为 http://127.0.0.1:8080/b.js 才是正确的

认真查看 browserify-loader.js
我把 2758 行的 var absoluteUri = url.resolve(y, x) 修改成 var absoluteUri = x 后
终于解决这个问题了。

不知道我是否有理解错误?我认为 url.resolve(y, x) 是不必要的。

xhr version has status === 0

the version of xhr you use has a check for status ===0 which is returned from a file:// url, this prevents

if (status === 0 || (status >= 400 && status < 600)) {

this module from being used in chromium with

chromium --allow-file-access-from-files

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.