rstacruz / flatdoc

Build sites fast from Markdown
http://ricostacruz.com/flatdoc
2.68k stars 263 forks source link

Does not work with webpack #98

Open mebibou opened 6 years ago

mebibou commented 6 years ago

I was using flatdoc in my project without using webpack and it used to work fine, now that I switched to webpack I have this error when trying to load a file:

Uncaught TypeError: Cannot read property 'setOptions' of undefined
    at Object.Parser.setMarkedOptions (flatdoc.js?2f77:185)
    at Object.Parser.parse (flatdoc.js?2f77:171)
    at eval (flatdoc.js?2f77:464)
    at loadData (flatdoc.js?2f77:53)
    at Object.eval (flatdoc.js?2f77:62)
    at fire (jquery.js?eedf:3317)
    at Object.fireWith [as resolveWith] (jquery.js?eedf:3447)
    at done (jquery.js?eedf:9272)
    at XMLHttpRequest.eval (jquery.js?eedf:9514)

I managed to hack this by installing marked directly (npm install marked --save), then before I import flatdoc I assigned marked to window, basically:

window.marked = require('marked');
import 'flatdoc';

Which means I now have marked twice imported.

SteveBenner commented 5 years ago

Perhaps this is an issue with Webpack usage, not flatdoc? Check this out:

https://formidable.com/blog/2018/finding-webpack-duplicates-with-inspectpack-plugin/