Comments (7)
If I would require.resolve
that in the primus library your files would end up missing as it would search the directory of the primus module not the directory of your primus plugin.
I can just check if the library is an array and do a simple:
if (Array.isArray(plugin.library)) library += plugin.library.map(function (path) {
return fs.readFileSync(path, 'utf-8');
}).join('\n');
I don't have a problem with that at all :)
from primus.
At least, if that is what you want ;)
from primus.
I see. glob, like in grunt, would be useful, since it translates to real paths to the files, since you can specify the src
, so it would know where to start searching. indeed, require.resolve
isn't the way to go, and the problem is more dificult to solve than it sounds. unless the directory (before readFileSync
) is forcefully appended with the required plugin file path, but that would need a change in the use
function to accept options I guess.
from primus.
I honestly don't the big problem here, what's the problem with doing a require.resolve
in the plugin?
from primus.
well, relative paths won't work, unless it's __dirname + 'library.js'
, the require will know where to look for them. mostly because of that. relative paths like ./file.js
or ../../file.js
won't work unless you use the current plugin file path (that is unknown to primus, since you use primus.use
with an already require'd module).
from primus.
Why would need relative paths? What's wrong with the __dirname & resolve approach?
from primus.
nothing, it just need to be stated explicity in the readme that the library paths (that will be concat'ed) need to be absolute instead of relative. that would be the only catch, else, everything is fine
from primus.
Related Issues (20)
- Missing dependencies for parser: "json" HOT 1
- Primus->diagnostics->storage-engine forces --unsafe-perm in global install HOT 4
- update documentation to be more explicit around createSocket
- Problem using proxy with primus client side
- Nativescript support HOT 1
- Does the primus web client work with a non-primus websocket server? HOT 4
- How can I know if a connection has been upgraded or not? HOT 4
- import primus client in client JS
- Getting response headers while polling HOT 3
- public connections and connected HOT 1
- Consider to rewrite without prototype pollution? HOT 11
- Primus with Koa and websockets transport HOT 3
- Can you please consider changing "Primus, the creator god of transformers" HOT 3
- primus doesn't accept custom path with engine.io HOT 10
- async plugins support HOT 8
- support of the new uwebsocket version
- Allow Primus instance to select version of transformer/engine library
- Server Side Events (SSE) source HOT 7
- Maximum Concurrent Connection on Primus Server HOT 2
- Consider alternative to deprecated navigator.userAgent getter. HOT 1
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 primus.