GithubHelp home page GithubHelp logo

test-mass-forker-org-1 / vscode-loader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/vscode-loader

0.0 0.0 0.0 677 KB

An universal Asynchronous Module Definition (AMD) Loader developed primarily to load VSCode's sources.

License: Other

JavaScript 60.26% TypeScript 36.32% CSS 1.49% HTML 1.94%

vscode-loader's Introduction

VSCode Loader

An universal Asynchronous Module Definition (AMD) Loader developed primarily to load VSCode's sources.

Supported environments

  • Edge, Firefox, Chrome, Safari
  • nodejs
  • electron (renderer & browser processes) In nodejs and electron, when loading a module, if it cannot be found with the AMD rules, it delegates loading them to the native require.

Features

  • Runs factory methods as soon as dependencies are resolved.

Using

  • In a browser environment:
<script type="text/javascript" src="loader.js"></script>
<script>
	require.config({
		// ...
	});
	require(['an/amd/module'], function(value) {
		// code is loaded here
	});
</script>
  • In a node environment:
var loader = require('loader');
loader.config({
	// ...
});
loader(['an/amd/module'], function(value) {
	// code is loaded here
});
  • Supported config options:
  • baseUrl - The prefix that will be aplied to all modules when they are resolved to a location
  • paths - Redirect rules for modules. The redirect rules will affect the module ids themselves
  • config - Per-module configuration
  • catchError - Catch errors when invoking the module factories
  • recordStats - Record statistics
  • urlArgs - The suffix that will be aplied to all modules when they are resolved to a location
  • onError - Callback that will be called when errors are encountered
  • ignoreDuplicateModules - The loader will issue warnings when duplicate modules are encountered. This list will inhibit those warnings if duplicate modules are expected.
  • isBuild - Flag to indicate if current execution is as part of a build.
  • cspNonce - Allows setting a Content Security Policy nonce value on script tags created by the loader.
  • nodeRequire - The main entry point node's require
  • nodeInstrumenter - An optional transformation applied to the source before it is loaded in node's vm

Custom features

  • Recording loading statistics for detailed script loading times:
require.config({
	recordStats: true
});
// ...
console.log(require.getRecorder().getEvents());
  • Extracting loading metadata for a bundler:
var loader = require('loader');
loader.config({
	isBuild: true
});
// ...
console.log(loader.getBuildInfo());

Testing

To run the tests:

  • code loading in node: npm run test
  • amd spec tests, unit tests & code loading in browser:
    • npm run simpleserver
    • open http://localhost:9999/tests/run-tests.htm

The project uses as a submodule the AMD compliance tests. The goal is to support as many tests without adding eval() or an equivalent. It is also not a goal to support loading CommonJS code:

  • Basic AMD Functionality (basic)
  • The Basic require() Method (require)
  • Anonymous Module Support (anon)
  • CommonJS Compatibility (funcString)
  • CommonJS Compatibility with Named Modules (namedWrap)
  • AMD Loader Plugins (plugins)
  • Dynamic Plugins (pluginsDynamic)
  • Common Config: Packages
  • Common Config: Map
  • Common Config: Module
  • Common Config: Path
  • Common Config: Shim

Developing

  • Clone the repository
  • Run git submodule init
  • Run git submodule update
  • Run npm install
  • Compile in the background with npm run watch1 and npm run watch2

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

License

MIT

vscode-loader's People

Contributors

alexdima avatar jrieken avatar dbaeumer avatar chrisdias avatar samb avatar bpasero avatar friedemannsommer avatar lramos15 avatar lweichselbaum avatar andarist avatar robertoaraujom avatar tylerleonhardt avatar ggilmore avatar

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.