Handling NPM dependencies

I’m somewhat new to the Purescript ecosystem and am trying to figure out how to handle NPM dependencies in my Halogen project.

Specifically, I’m trying to use choices.js.

  • I’ve installed it using npm install --save choices.js

  • I created a pair of FFI .js/.purs modules

  • The .js module uses import Choices from 'choices.js'; to import the package

  • I’m running the app with live reload by running spago build && parcel dev/index.html --open

  • I’m building for production using a combination of spago bundle + parcel build

  • Note: I’m using spago@next

The purescript code is indeed able to read and use the js module choices.js (I can see the select element being displayed on the UI), but it seems the package also depends on additional CSS files in order to work correctly, which, as far as I can tell, are located here:

  • node_modules/choices.js/public/assets/styles/base.min.css

  • node_modules/choices.js/public/assets/styles/choices.min.css

How would I go about ensuring these additional files from NPM packages are also available?

1 Like
  • The .js module uses import Choices from 'choices.js'; to import the package

Since you’re using Parcel, I think you could import the CSS in that same file and it should work. Try adding:

import "choices.js/public/assets/styles/choices.css";

(grabbed that from the README: GitHub - Choices-js/Choices: A vanilla JS customisable select box/text input plugin ⚡️)