0

I have some PureScript code that looks like this

module Types.ScriptLookups2 where

import Prelude

require :: Unit
require = unit

and it gets compiled to the JavaScript code

// Generated by purs version 0.14.9
"use strict";
var Data_Unit = require("../Data.Unit/index.js");
var require = Data_Unit.unit;
module.exports = {
    require: require
};

It seems, at least by default, webpack is not smart enough to redefine the earlier requires and then leave the final one alone. What happens instead is that webpack doesn't touch the require function at all, leading to errors because there is no require in the browser. Is there any webpack configuration I can do to fix this, or do I need to work around it by other means? Unfortunately in the real code, this comes from a dependency, so it's not as easy as renaming it and moving on.

Mason
  • 738
  • 7
  • 18
  • https://stackoverflow.com/questions/65342075/import-images-like-in-typescript – James Brock Jun 27 '22 at 05:12
  • Not sure if upgrading PureScript is an option for you, but PureScript 15 emits ES modules instead. This might circuvent the problem. – Herku Jul 19 '22 at 16:03
  • Unfortunately it's not. But I got the authors to rename the function, it was an internal one anyway. – Mason Jul 20 '22 at 18:02

0 Answers0