Comments (8)
Some of the codes for reference
define(function(require, exports, module) {
main.consumes = ["Plugin", "commands", "tabManager", "run"];
main.provides = ["rating"];
return main;
function main(options, imports, register) {
//var opt = "/home/derek/nvm/v0.10.28/lib/node_modules";
var Plugin = imports.Plugin;
var commands = imports.commands;
var tabs = imports.tabManager;
var run = imports.run;
var settings = imports.settings;
var save = imports.save;
var esprima = require("esprima");
var estraverse = require('estraverse');
var escope = require('escope');
from core.
The require statement will cause error because those modules are not provided in defined.
I am quite new to this, but from my understanding, the require function is used to call a bunch of defined module within cloud9. Hence it doesn't retrieve module added elsewhere. Is there a way I can call external node modules?
from core.
You can use require() for normal client-side dependencies, but for node-style modules, you need something like browserify to wrap then in a way they can be imported in the client. Note that escope appears to already have a gulp command for this at https://github.com/estools/escope/blob/548ba8b390215a29dea065fe096e20665ff98444/gulpfile.js#L82. It should be possible to do something similar with esprima. Another thing you could have a look at is our eslint plugin, which includes a browserified version of eslint (https://github.com/c9/c9.ide.language.javascript.eslint/blob/master/worker/eslint_browserified.js). eslint includes esprima and estraverse. I'm not sure you can directly use them from there, but it's worth taking a look at anyway as it shows some patterns for doing syntax analysis. The docs at https://docs.c9.io/api/#!/api/language provide some more background on this topic.
from core.
@FAGundum Did @lennartcl's answer help you? Can this issue be closed?
from core.
Hi @javruben and @lennartcl , thanks for the answer. The issue can be closed.
from core.
Hi, @lennartcl , actually I have one more issue related to browserify.
Once I have browserified, say for example, https://github.com/estools/escodegen. I use the escodegen.browser.js provided by them. It basically bundled a couple of scripts together, including esutils, estraverse, escodegen etc....
When I require this browserified script in my plugin,
var escodegen = require('./escodegen.browser');
The rendered escodegen variable is not a escodegen object, in fact, it is rendered to be a estraverse object. My guess is that the require function is not able to recognize escodgen object in escodegen.browser.js, instead it takes the last defined object in the file. (in this case, it happened to be estraverse)
This also happened to escope once I browserified it.
One screenshot of my debug window.
Just wondering, how can I resolve this issue. Should I require this script with some other configurations?
from core.
@FAGundum by default browserify exports only one module to the global scope.
As a workaround you can create a module like
exports.esutils = require('esutils')
exports.estraverse = require('estraverse')
and browserify it instead
but that's not very nice.
I'll look if it's possible to get architect-build to work for node modules without requiring browserify step.
from core.
Great, thanks for the answer. I will look into it. I am going to close this issue.
from core.
Related Issues (20)
- Self hosted --collab share error
- Failed to install SDK in Mac OS 10.14.3 HOT 1
- Error creating TMUX session: Cannot read property 'on' of undefined HOT 3
- hide toolbar
- Full Java support?
- Is this project dead? HOT 9
- no more update? HOT 2
- Vulnerabilities
- Can i integrate cloud9 ace editor separately
- Fresh install - git extension not working
- List of flags HOT 2
- Connect to the IDE from a subdomain? HOT 2
- Require password to access Theia in browser?
- connect to SSH workspace from self hosted c9 SDK
- Error: Cannot find module 'c9/urls'
- Python 2 out of support. HOT 1
- Failed to write to 'state.settings'. options.stream must be readable. HOT 8
- How to delete cloud9?
- C9 Sudden stop,
- download and parse revision history
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 core.