transforming data during build in a vite project that uses eslint and typescript #20834
Unanswered
stuvjordan-uroc
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Everyone!
I need to transform some data during the build stage. The data that needs to be transformed are in local files in my project, and so my first instinct in writing the transformation scripts was to use node's standard filesystem library.
I'm finding, however, that this requires modifications to the eslint.config.js and/or tsconfig produced by
npm create vite@latest
that go way beyond my very slim knowledge of eslint and typescript configuration. (I should probably also say that I'm writing all my code in typescript.)This raises two questions for me:
Can anyone recommend a community template that includes configs of eslint and typescript that accommodate use of "node:fs" and other such standard nodejs modules by build scripts written in typescript? I'm asking because I'm guessing that it's not uncommon for developers using vite (with eslint and typescript) to need to use nodejs libraries during build.
As an alternative, it occurs to me that I could just
import
the contents of the datafiles as strings in the build scripts, since the eslint and typescript configs provided bynpm create vite@latest
are set to understand that way of usingimport
. This may not be ideal in my case, as the files I need to transform are very large, so I may need to stream them depending on the memory resources of my dev environment. (And perhaps I should also say that I definitely do NOT want these files bundled nor do I want to put them in the /public folder.) I guess my question here is for experienced developers who use vite: What's the recommended way to solve this problem? Tuning eslint.config.js so that you can use "node:fs" in build scripts, or instead just usingimport
to load data into a build script? (Or is there some alternative approach that beats those two?)Thanks!
Beta Was this translation helpful? Give feedback.
All reactions