-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webpack require fails #277
Comments
If I require the dist min file: Critical dependencies:
1:437-444 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ./~/mermaid/odist/mermaid.min.js 1:437-444 It works that way, but makes impossible for me to access the yy object completely. |
In package.json the entry point is pointing to src/mermaid.js
This is the file that should be required. Hope that pointer helps and let me know how it goes. |
I required that file directly as well. Result is the same as I wrote above. |
I'm also having a similar problem using webpack
|
I have a fork that "mostly" works with webpack The key changes are There are still a few warnings but I was hoping this fork would inspire mermaid to become webpack compatible. |
Is there any progress with this issue? |
has the same issue, any progress? |
so apparently this is fixed in webpack 2.0, but now i get a different error:
|
I have the same problem with webpack 2.0 and don't know how to resolve it |
@dcsan react-mermaid.js is using The wrapper is... very minimalistic. I suggest using the mermaid version current in npm. |
It seems to be a dragre-d3 problem - dagrejs/dagre-d3#129 |
Why is the I have it working so far by:
I'll see if I can make a Pull Request to fix this soon. Update: This is the error I am seeing with Webpack using
However, when I clone and build ( |
Ok, so I have it working now. Step 1: Require from
|
Before | After |
---|---|
require('mermaid'); |
require('mermaid/dist/mermaid.js'); |
Likewise, I have the CSS working with Webpack using require('mermaid/dist/mermaid.css')
and css-loader.
Step 2: Workaround for Jison bug
After step 1 I receive an error Invalid labeled declaration
about the _token_start:
lines.
Unfortunately, a fix has yet to be applied to Jison. See zaach/jison#351 and zaach/jison#352
For now, we can provide a workaround.
Step 2.1: Create fixMermaid
script
Create a file named scripts/fixMermaid.js
with the following contents:
#!/usr/bin/env node
const { readFileSync, writeFileSync } = require('fs');
const path = require('path')
const mermaidPath = path.resolve(__dirname, '../node_modules/mermaid/dist/mermaid.js');
console.log(`Fixing Mermaid JS file at ${mermaidPath}`);
const contents = readFileSync(mermaidPath, 'utf8');
// Remove _token_stack label manually until fixed in jison:
// https://github.com/zaach/jison/issues/351
// https://github.com/zaach/jison/pull/352
const fixedContents = contents.split('_token_stack:').join('');
writeFileSync(mermaidPath, fixedContents, 'utf8');
console.log('Fixed Mermaid!');
Of course, you do not need to name it fixMermaid.js
or place it within a directory named scripts
. If you change this structure, please be sure to change the following steps, too.
Step 2.2: Run Mermaid after npm install
has completed
Edit your package.json
to include the postinstall
script:
{
"scripts": {
"postinstall": "node scripts/fixMermaid.js"
}
}
Step 3: Profit!
Now when you run npm install
and then webpack
, it should all work! 💥
❯ npm install
> postinstall
> node scripts/fixMermaid.js
Fixing Mermaid JS file at ./node_modules/mermaid/dist/mermaid.js
Fixed Mermaid!
Problem resolved and this is an official fix: #361 (comment) In short: latest version of mermaid has no problem with webpack. |
Please also check mermaid-webpack-demo. |
Requiring the package with Webpack fails in my web-project:
The text was updated successfully, but these errors were encountered: