Comments (2)
/lib/internal/modules/cjs/loader.js
about line 860
Module._resolveFilename = function(request, parent, isMain, options) {
if (StringPrototypeStartsWith(request, 'node:') ||
NativeModule.canBeRequiredByUsers(request)) {
return request;
}
////////////////////////////////////////////
//#espresso, #4
if (request.endsWith(".espr")) {
return request;
}
////////////////////////////////////////////
let paths;
patch 4: /lib/internal/modules/cjs/loader.js
about line 1123
// Native extension for .js
Module._extensions['.js'] = function(module, filename) {
if (StringPrototypeEndsWith(filename, '.js')) {
const pkg = readPackageScope(filename);
// Function require shouldn't be used in ES modules.
if (pkg?.data?.type === 'module') {
const parent = moduleParentCache.get(module);
const parentPath = parent?.filename;
const packageJsonPath = path.resolve(pkg.path, 'package.json');
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
}
}
// If already analyzed the source, then it will be cached.
const cached = cjsParseCache.get(module);
let content;
if (cached?.source) {
content = cached.source;
cached.source = undefined;
} else {
content = fs.readFileSync(filename, 'utf8');
}
module._compile(content, filename);
};
//////////////////////////////////
//#espresso, #5
Module._extensions['.espr'] = function (module, filename) {
//this make node to callback to our module
var content = LibEspresso.LoadMainSrcFile();
module._compile(content, filename);
};
//////////////////////////////////
patch 5: /lib/internal/modules/cjs/loader.js
from espresso.
file /lib/internal/main/run_main_module.js
line 1
'use strict';
const {
prepareMainThreadExecution
} = require('internal/bootstrap/pre_execution');
prepareMainThreadExecution(true);
markBootstrapComplete();
// Note: this loads the module through the ESM loader if the module is
// determined to be an ES module. This hangs from the CJS module loader
// because we currently allow monkey-patching of the module loaders
// in the preloaded scripts through require('module').
// runMain here might be monkey-patched by users in --require.
// XXX: the monkey-patchability here should probably be deprecated.
//////////////////////////////////
//#espresso, #6
/////////////////////////////////
if (typeof LibEspresso !== 'undefined') {
//we use our lib espr LibEspresso
require('internal/modules/cjs/loader').Module.runMain("hello.espr");
return;
}
/////////////////////////////////
require('internal/modules/cjs/loader').Module.runMain(process.argv[1]);
patch 6: /lib/internal/main/run_main_module.js
from espresso.
Related Issues (20)
- Node 10 and N-API support HOT 1
- Issue sending C# arrays to Javascript engine HOT 5
- Add debugger support to ND version HOT 4
- Access Violation in CreateWrapperForManagedObject HOT 17
- DoGetterProperty and DoSetterProperty HOT 1
- upgrade to v8 engine from NodeJs 8.9.3
- upgrade to v8 from node9.3.0
- HowTo HOT 2
- Implementation for Deno
- Run MathJax in C# using Espresso HOT 3
- Espresso, NodeJS 10.15.1 HOT 5
- Espresso, NodeJS 10.15.3 HOT 6
- Espresso, NodeJS 11.12.0 HOT 3
- JsEngine.CompileScript System.AccessViolationException HOT 1
- Access Inspector Protocol for Debugging non-Node JS HOT 1
- Espresso, NodeJS 12.7 HOT 1
- Espresso, NodeJS 12.11.1 HOT 3
- Espresso, NodeJS 13.5.0 HOT 2
- Espresso, NodeJS 16.8.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from espresso.