Comments (5)
Hello @KylePDavis ,
I think puppeteer
is too big to be installed locally. The mume
project is used in vscode-markdown-preview-enhanced project, which is an extension for visual studio code. However, visual studio code has file size limit for its extension. If I put puppeteer
inside package.json
and install it locally, then the file size of packed vscode extension will exceed. That's why I decide to make it require globally.
However, it's quite hard to require puppeteer globally because it's hard to find the path of where it is installed. Apparently requireg
doesn't work well. I am using nvm, and it seems that requireg
returns me the wrong path. And it doesn't work well on Windows either.
Therefore, my plan is to let user enter the path of puppeteer
like:
const engine = new mume.MarkdownEngine({
filePath: "/Users/wangyiyi/Desktop/markdown-example/test3.md",
config: {
previewTheme: "github-light.css",
puppeteerPath: "/usr/local/node_modules/puppeteer"
}
})
What do you think?
from crossnote.
Thanks for the quick response! I definitely think that puppeteer
is too big to be included with markdown-preview-enhanced
. On the other hand, I don't think that mume
should prevent it's consumers from doing that if they want to.
In my case, I'm trying to use mume
as a dependency and want to also depend on puppeteer
. Since what I'm doing doesn't have the same restrictions, it's perfectly reasonable to package it that way (and anyone depending on my package could tweak the puppeteer
install via a few environment variables if needed).
Your idea for providing an option for where puppeteer
might work, and might even be necessary for some cases, but I hope not. I'd really like to see if we can come up with something better before making consumers do extra work.
I'm thinking something as simple as trying to resolve against a list of paths. Then maybe if there are still edge cases you could allow them to override that list of module directories but hopefully that won't be necessary. What about trying the list of paths provided by the global-paths package?
Then you could do something like this:
const path = require('path');
const getGlobalPaths = require('global-paths');
function requireFromPaths(id, paths) {
for (let p of paths) {
try { return require(path.join(p, id)); } catch(err) { /* next... */ }
}
throw new Error(`Unable to load "${id}" from: ${paths.join(',')}`)
}
// ... some where later in the code ...
puppeteer = requireFromPaths('puppeteer', getGlobalPaths());
from crossnote.
Hi @KylePDavis ,
This issue should be fixed now. Please check this line.
Basically I call command npm root -g
to get the path to global node_modules directory.
Then I require puppeteer
from that.
So if you have puppeteer installed globally by npm install -g puppeteer
, then the chrome (puppeteer) export should work.
Thanks
from crossnote.
Hey @shd101wyy, thanks for looking into this. It looks like that code forces global module resolution but here I actually need the ability to use the standard local module resolution.
It would be much better for me if I could simply use the version of puppeteer
that I have specified in my package's package.json
file. This is much more reliable than hoping that the user has already globally-installed a compatible version of the puppeteer
module.
In other words, I want to prefer local modules first but then fallback to global modules.
I see two viable approaches here:
- allow users of the
mume
package to specify apuppeteerPath
config option (the module path) - modify the
mume
package to search for local modules and then global modules upon failure
Long-term I think approach [2] is better but short-term I could make approach [1] work if you would rather do that instead. Even longer-term it might even make sense to do both approach [2] and approach [1].
Does that better explain what I'm after here?
from crossnote.
It would be great if you can submit me a pull request.
from crossnote.
Related Issues (20)
- 自定义 markdown-it 扩展不支持?
- Inconsistant Wikilink Logic
- Upgrade to Wavedrom 2.9.1 HOT 1
- [Bug] Unable to export graph using pandoc
- Security vulnerability in cheerio v1.0.0-rc.3
- [Feature Request] Pandoc grid tables HOT 1
- Unable to overwrite java executable for plantuml HOT 1
- [Vulnerability] OS command injection in PDF import functionality HOT 1
- [Vulnerability] OS command injection via Memraid PNG export HOT 1
- Support bitbucket server TOC (Each markdown title must have it's own anchor)
- [Feature Request] add copy-to-clipboard class to code chunk
- Support curly brackets around code block language/graph type name
- [Feature] Is this alternative way to set global LaTeX macros possible?
- Delete images uploaded to imgur by mistake
- Don't write config file templates HOT 1
- After updating the latest version, there seems to be an issue with the rendering of the sequence diagram? HOT 2
- [Feature Request] Proposal of supporting matplotlib-type preview for other Python tools like Pipenv HOT 2
- Uploaded images
- [BUG] `github-dark.less` style error HOT 1
- [BUG] ESM support is broken
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 crossnote.