question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crashing due to Critters.prototype.readFile vs. this$1.fs

See original GitHub issue

Using new Critters() without (in the usual Webpack plugins array) any options causes the compilation process to crash:

ERROR in TypeError: Cannot read property 'readFile' of undefined
  - critters.js:216 
    [LianaUI]/[critters-webpack-plugin]/dist/critters.js:216:19
 . . .
  - critters.js:215 Critters.readFile
    [LianaUI]/[critters-webpack-plugin]/dist/critters.js:215:12
  
  - critters.js:272 Critters.<anonymous>
    [LianaUI]/[critters-webpack-plugin]/dist/critters.js:272:25
. . .
  - critters.js:258 Critters.embedLinkedStylesheet
    [LianaUI]/[critters-webpack-plugin]/dist/critters.js:258:12
  
  - critters.js:233 
    [LianaUI]/[critters-webpack-plugin]/dist/critters.js:233:83
. . .

^ Seems to break on Critters.prototype.readFile = function readFile(filename, encoding) {...} because this$1.fs is undefined.

Tried with:

"html-webpack-plugin": "3.2.0"
"webpack": "4.12.0"
"webpack-dev-server": "3.1.4"
"critters-webpack-plugin": "1.0.0"

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:11

github_iconTop GitHub Comments

2reactions
isidrokcommented, Sep 14, 2018

Hi @DavidCondit, I was having that problem because there seems to be a conflict when using mini-css-extract-plugin and prerender-loader. prerender-loader was outputing incorrect hashes for the css files which could not be resolved later by Critters but using contenthash did work.

Here is my relevant configuration:

const HASH = 'contenthash';
{
entry: resolve('src/index.js'),
output: {
  filename: `static/js/[name]${HASH}.js`,
  chunkFilename: `static/js/[name]${HASH}.js`,
  path: resolve('dist'),
  publicPath: '/',
  },
plugins: [
  new webpack.HashedModuleIdsPlugin(),
  new MiniCssExtractPlugin({
    filename: `static/css/[name]${HASH}.css`,
    chunkFilename: `static/css/[name]${HASH}.css`,
  }),
 new HtmlWebpackPlugin({
    template: `!prerender-loader?string!${resolve('public/index.html')}`,
    minify: {
      removeComments: true,
      collapseWhitespace: true,
      removeRedundantAttributes: true,
      useShortDoctype: true,
      removeEmptyAttributes: true,
      removeStyleLinkTypeAttributes: false,
      keepClosingSlash: true,
      minifyURLs: true,
    },
  }),
  new Critters(),
}

Will try to reproduce that prerender-loader behaviour with a minimal example and open an issue in that repo.

1reaction
MikaAKcommented, Oct 31, 2018

That did the trick!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Studio Prototype - Not Loading & Crashing - InVision Support
My prototype loads ok (a little slow) on web app but takes forever to load on Mobile App 2.7.3 (489) on iPhoneX iOS...
Read more >
node.js - FS (save/read) Crashes electron - Stack Overflow
I'm trying to build an electron app and i can't seem to get FS (file-system) to work without crashing Electron.
Read more >
How to fix Prototype crashes (Desktop and Mobile)?
Hi people! I'm building a prototype for mobile (iPhone 11 Pro) with about 45 screens without using any plugin and only Google Fonts...
Read more >
Prototype 2 Windows 11 2022 Crash Fix - YouTube
Had an older vid up for the pounce mission on Windows 10, here's an updated version for Windows 11! :)-------0:00 Windows Version 21H20:47 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found