sass / dart-sass

The reference implementation of Sass, written in Dart.
https://sass-lang.com/dart-sass
MIT License
3.9k stars 352 forks source link

Node Package Importer can't find ESM entry point if args are provided #2188

Closed jamesnw closed 6 months ago

jamesnw commented 6 months ago

Currently, it appears that an entryPoint is only found if argv has exactly 2 arguments.

I'm observing this in a Vite project, with the css key in vite.config.ts setting up the package importer using the legacy API-

css: {
    preprocessorOptions: {
      scss: {
        includePaths: [path.resolve('./src/sass/')],
        pkgImporter: new NodePackageImporter(),
      },
    },
  },

Running yarn vite works, but yarn vite dev fails with the The Node package importer cannot determine an entry point becauserequire.main.filenameis not defined. error. Stepping through sass.dart.js in the debugger, I can see that the value of process.argv contains 3 values, and so if (process.argv case [_, String path]) does not match.

We have worked around this issue by providing "." as an entry point to the NodePackageImporter.

ntkme commented 6 months ago

I think it's as easy as

-  } else if (process.argv case [_, String path]) {
+  } else if (process.argv case [_, String path, ...]) {