FHIR Chat · LHC-Forms and npm · questionnaire

Stream: questionnaire

Topic: LHC-Forms and npm


view this post on Zulip Paul Lynch (Mar 01 2022 at 20:26):

We are considering ceasing publication of LHC-Forms as a npm package, and just directing people either to download built versions from https://clinicaltables.nlm.nih.gov/lforms-versions or to build it themselves. The reason for this is that as of version 30, LHC-Forms is now a web-component, which is meant to encapsulate and isolate its resources from the surrounding page, so npm's idea of shared packages with the containing app does not apply anymore. I think if we published to npm, what we would include there would be the same set of files downloadable from https://clinicaltables.nlm.nih.gov/lforms-versions, i.e. the built files minimized and bundled together with the dependencies, which seems odd for npm. I am also not sure an "import" of those files would work-- you might have to copy them out of node_modules and include them with script tags, just as if you has downloaded them.

So the question is, is any using the npm package for LHC-Forms for whom switching to downloading the package would be an issue?

view this post on Zulip David Winters (Mar 02 2022 at 11:19):

Hey @Paul Lynch, so happy you made the jump to web components! I'd encourage you to keep publishing to npm, since I know many front-end apps are built using it to manage dependencies. I can imagine wanting to pull in lhc-forms from npm and injecting into an app, which would be much easier to do if it was still on npm. It looks like your current distribution includes all the dependencies and polyfills, but someone using your package on npm might want to bundle in their own.

view this post on Zulip David Winters (Mar 02 2022 at 11:20):

So I agree it probably doesn't make sense for you to just push your dist folder to npm. Ideally you would just publish the raw web components and specify the dependencies in your package.json file. Then it would be up to users to polyfill if they're targeting an older browser.

view this post on Zulip David Winters (Mar 02 2022 at 11:23):

Also super cool that you're using TypeScript :)

view this post on Zulip David Winters (Mar 02 2022 at 11:31):

If you're interested in supporting npm, you could try following the approach that SurveyJS takes. They have the core TS library which they then build for integration with different front-end frameworks (e.g., React, Angular, etc.). It's these integrations they then publish on npm. Here's an example package.json which you can see is just a group of minified files with a single point of entry that you can import into your project. Their build process looks pretty complicated, but I think for your case it would be much simpler since you just have the WCs and I don't think are doing anything special for specific frameworks.


Last updated: Apr 12 2022 at 19:14 UTC