JavaScript is a powerful object-oriented language, and it has many fast and efficient interpreters. The official JavaScript standard defines the API for building browser-based applications. However, it is not set in a standard library for a wider range of applications. The CommonJS API fills this gap by defining APIs that are used by many common applications, primarily non-browser applications . Its ultimate goal is to provide a library of standards l
The first part of this series introduces the basic wording of the JavaScript module, and today describes how to use the module in a canonical manner.VII. Specification of modulesFirst think about why the module is important?Because of the module, we can more easily use other people's code, want what function, load what module.However, this has a premise, that is, we must write the module in the same way, otherwise you have your writing, I have my writing, it is not messy set! This is even more i
feature is the synchronous loading of the JavaScript module, running on the server side. node. JS is an implementation of the COMMONJS specification.Commonjs the definition of the module is very simple, divided into module definition (exports), module reference (Require), module marked three parts.Returns the object that the current module wants to supply to other modules through the global variable exports:1//Definition behavior 2 function foobar ()
Modules/Wrappings makes implementation a reality. Although it is not exactly the same as the node. js module writing method, there are also many similarities, so that programmers familiar with node. js have some intimacy.
But NodeJS is the JavaScript on the server end after all, and there is no need to put these lines in the browser's JavaScript environment. At this time, AMD was born, and its full definition is called asynchronous module. It is known from the name that it is suitable for script
Node. js package details, Node. js package details
In Node. in js language, packages and modules are not essentially different. packages are further abstracted Based on modules. Packages encapsulate an independent function, it is used for release, update, dependency management, and version control. Node. js implements the package mechanism according to CommonJS specifications, and develops npm to meet the package release and acquisition requirements.
a module.exports by exports direct Assignment. Exports is actually just a variable that points to the same object as the module.exports, which itself is released after the module execution ends, but module does not, so you can only change the provider by specifying MODULE.EXPORTS.A package is a further step on the basis of a module, and Node. Js's package is similar to a C + + library or java/. Net's class library, which encapsulates a separate feature for publishing, updating, dependency manag
generally refers to something that manages AMD or CommonJS modules.
Good...... , what is AMD and CommonJS?
is a two definition. There are many ways to describe how multiple libraries or classes in JS interact, such as exports and requires. You can follow the AMD or CommonJS API to write JS, and then use Browserify to package them.
It sounds rea
The first part of this series introduces the basic wording of the JavaScript module, and today describes how to use the module in a canonical manner.VII. Specification of modulesFirst think about why the module is important?Because of the module, we can more easily use other people's code, want what function, load what module.However, this has a premise, that is, we must write the module in the same way, otherwise you have your writing, I have my writing, it is not messy set! This is even more i
environment.FinishJavaScript modular Programming (II): AMD specificationsNanyiDate: October 30, 2012The first part of this series introduces the basic wording of the JavaScript module, and today describes how to use the module in a canonical manner.(next to the above)VII. Specification of modulesFirst think about why the module is important?Because of the module, we can more easily use other people's code, want what function, load what module.However, this has a premise, that is, we must write
The first part of this series introduces the basic wording of the JavaScript module, and today describes how to use the module in a standardized way, first think about why the module is important? Next for your detailed introduction, interested friends can understand the next AH. Today describes how to use modules in a canonical manner.VII. specification of modulesfirst think about why the module is important? Because of the module, we can more easily use other people's code, want what function,
I. Specification of modulesFirst think about why the module is important?Because of the module, we can more easily use other people's code, want what function, load what module.However, this has a premise, that is, we must write the module in the same way, otherwise you have your writing, I have my writing, it is not messy set! This is even more important considering that the JavaScript module does not yet have an official specification.Currently, there are two types of JavaScript module specifi
In Node.js languages, packages and modules are not fundamentally different, packages are a deeper abstraction on the basis of a module, and packages encapsulate a separate function for publishing, updating, dependency management, and versioning. Node.js implemented the package mechanism according to the COMMONJS specification and developed NPM to solve the package release and acquisition requirements.
The Node.js package is a directory that contains
The first part of this series introduces the basics of JavaScript modules and today describes how to use modules in a standardized way.
(up to the above)
Specification of Modules
First think about why the module is important?
Because of the module, we can more easily use other people's code, want what function, loaded what module.
However, this has a prerequisite, that is, we must write the same way the module, otherwise you have your writing, I have my writing, it is not a mess of the se
people's code, want what function, load what module.However, this has a premise, that is, we must write the module in the same way, otherwise you have your writing, I have my writing, it is not messy set! This is even more important considering that the JavaScript module does not yet have an official specification.Currently, there are two types of JavaScript module specifications available: Commonjs and AMD. I mainly introduce AMD, but start with Com
Disclaimer: Web logs reproduced from NanyiThe first part of this series introduces the basic wording of the JavaScript module, and today describes how to use the module in a canonical manner.(next to the above)VII. Specification of modulesFirst think about why the module is important?Because of the module, we can more easily use other people's code, want what function, load what module.However, this has a premise, that is, we must write the module in the same way, otherwise you have your writing
4. Cyclic loading
"Cyclic loading" (circular dependency) refers to the execution of a script that relies on B scripts, while the execution of B scripts relies on a script
Typically, a "cyclic load" indicates a strong coupling and, if not handled properly, can also result in recursive loading, which prevents the program from executing and should avoid
But in fact, this is very difficult to avoid, especially in the complex dependencies of large projects, it is easy to have a dependent b,b depend
Why is web page modularization required ?, Need web page modularization?
This article discusses why Web modularization is useful and introduces some mechanisms that can be used to implement Web modularization. Another article introduces the design concept of function packaging format used by RequireJS.Question 1
Websites are gradually transformed into Web apps
Code complexity is gradually improved
Difficulty in assembling and changing
JS files/modules to be separated by developers
Code can
Background:Before ES6, JS language is not modular, how to let JS not only run in the browser, and can more effectively manage the code,Thus came into being COMMONJS this specification, defined three global variables:Require,exports,moduleRequire is used to introduce a moduleExports external Exposure module interface, can be any typeModule is the object of the modules themselvesWhen introduced with require, it is an externally exposed interface (export
arbitrarily modified internal membersmyModel.var1 = 100;This can lead to unexpected security problems.Execute function immediatelyThe purpose of hiding details can be achieved by executing functions immediately.var myModule = (function(){var var1 = 1;var var2 = 2;function fn1(){}function fn2(){}return {fn1: fn1,fn2: fn2};})();It's not possible to modify variables and functions outside of the module that we haven't exposed.The above approach is the basis of our modularity, currently, there are t
CONMMONJS, see Commonjs's Annotated information for Requirejs module mapping to the COMMONJS module).A disk file should only have 1 modules defined. Multiple modules can be packaged using built-in optimization tools.Definition of a module simple key-value pairsIf a module contains only value pairs and no dependencies, then the values are defined in define ():define({ name: "john", age : 20, sex : "femal"});Comments: This situation is not very usef
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.