The dart-sass dart compilation results in this sass.dart.js module: https://runpkg.com/?sass@1.21.0/sass.dart.js
Amongst other things, this contains (many lines redacted):
var self = Object.create(global);
self.require = require;
//...
u($,"N0","Hq",function(){return self.require("readline")})
u($,"Mr","cN",function(){return self.require("fs")})
u($,"MN","Ho",function(){return self.require("chokidar")})
This use of require
prevents static analysis by webpack, resulting in the error in the output (also in this gist) and a webpackEmptyContext
being created in the bundle. This naturally doesn't work :)
How can I configure the context for this particular module to specifically list readline/fs/chokidar as dependencies, possibly to produce some context that only provides those values?
I've seen the ContextReplacementPlugin, I don't think this applies here as the usage is not a direct require
call.
I've seen noParse
, but that feels like the nuclear approach, and I don't know what the potential negative side effects may be.
I don't mind if the solution is a little brittle and would require pinning of the version of dart-sass.