-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"The CJS build of Vite's Node API is deprecated." #431
Comments
Enabling "type": "module" in |
Sorry if this is a silly question, my JS environment managing knowledge is pretty basic... @jon-codes are you saying that's a change to vite-ruby that is required (vite-ruby's own package.json?), or this is something I just put in my own package.json? Can you provide an example of how to |
Sure @jrochkind, you can enable it in your own The Here's an example from my // package.json
{
"type": "module",
"scripts": {
"format": "prettier --check .",
"format:fix": "prettier --write .",
"lint": "eslint .",
"lint:fix": "eslint --fix ."
},
"dependencies": {
"@hotwired/turbo-rails": "^8.0.2"
},
"devDependencies": {
"@fullhuman/postcss-purgecss": "^5.0.0",
"@types/node": "^20.11.19",
"autoprefixer": "^10.4.17",
"eslint": "^8.56.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"postcss": "^8.4.35",
"postcss-nesting": "^12.0.2",
"prettier": "^3.2.5",
"vite": "^5.1.3",
"vite-plugin-rails": "^0.5.0"
},
"engines": {
"node": "20.11.1",
"npm": ">=10"
},
"os": [
"linux",
"darwin"
]
} I'm using a // vite.config.js
/* esbuild-env node */
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vite";
import RailsPlugin from "vite-plugin-rails";
// ESM modules do not have `__filename` and `__dirname` constants, unlike CJS modules.
// See: https://nodejs.org/api/esm.html#differences-between-es-modules-and-commonjs
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export default defineConfig({
plugins: [RailsPlugin()],
resolve: {
alias: {
"@vendor": resolve(__dirname, "vendor"),
"@fonts": resolve(__dirname, "assets/fonts"),
"@icons": resolve(__dirname, "assets/icons"),
"@images": resolve(__dirname, "assets/images"),
"@stylesheets": resolve(__dirname, "assets/stylesheets"),
},
},
}); |
Thank you for that explanation! I will have to go through it more slowly and try things out.
vite-ruby generator right now creates
Do you think this needs/should be changed? I think the file does not actually use anything that's non-JS typescript or anything like that? Not sure why it has had It looks like possibly the generated file needs to be different too, per your comments on |
Using vite-rails
3.0.17
, vite_ruby3.5.0
, and vite5.0.10
, I'm getting this deprecation warning output in my console when runningassets:precompile
.I upgraded to vite 5.x after upgrading to vite_ruby 3.5.0, as it seemed to prefer vite 5? But I wonder if it's triggering this deprecation warning in vite 5, and if that can/should be fixed?
The text was updated successfully, but these errors were encountered: