firepad icon indicating copy to clipboard operation
firepad copied to clipboard

Problems with webpack

Open ninjasort opened this issue 9 years ago • 5 comments

I'm using webpack to load modules and using Firepad's Headless npm module. When I import as such:

import Firepad from 'firepad';
const headless = new Firepad.Headless('https://myrefhere.firebaseio.com');

The module it shows two errors:

Critical dependencies:
14:3292-3299 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/firepad/dist/firepad.min.js 14:3292-3299
Critical dependencies:
2463:61-68 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/firepad/dist/firepad.js 2463:61-68

I also can't use it within a React callback function. The function doesn't call the callback.

headless.setText(content, (err, committed) => {
    console.log(err, committed); // not called
})

ninjasort avatar Oct 11 '16 01:10 ninjasort

@cameronroe The warnings and headless not working for you may be unrelated. I have received the same warnings while still getting everything to function correctly.

Things To Try

  1. Make sure your rules allow you to do this write operation
  2. Try passing a ref to Firepad instead of your url (i.e
firebase.initializeApp(config);
const headless = new Firepad.Headless(firebase.database.ref.child('yourChild'));

Webpack Sidenote

I also needed the expose loaded to get Codemirror working with Firepad in Webpack like so:

require('expose?CodeMirror!codemirror') // Needed for Firepad to load CodeMirror

prescottprue avatar Oct 11 '16 08:10 prescottprue

Hello,

I have encountered the same error. It can be easily reproduced by creation new angular project with firepad. It looks like firepad can't be used anymore.

I am curious if someone managed to solve this somehow.

zeratulinio avatar May 28 '17 20:05 zeratulinio

@zeratulinio Did you try the solution I posted? Still currently using this config and it is working for me.

prescottprue avatar May 29 '17 06:05 prescottprue

I have it functionally working as well, but it would be nice to setup Angular application in the way it doesn't show any warniings. @prescottprue @zeratulinio anyone has solution that would remove the warning?

opensso avatar Aug 08 '17 04:08 opensso

@opensso You can try adding firepad to the noParse options of webpack (i.e. do not send it through the loaders at all), but that broke stuff I was trying to use it with.

There is also a way to silence webpack warnings, but I enjoy other warnings so I don't want them gone all together.

prescottprue avatar Aug 08 '17 05:08 prescottprue