postcss-import icon indicating copy to clipboard operation
postcss-import copied to clipboard

v15 error when run in gulp via postCss and ESM

Open scottlet opened this issue 3 years ago • 5 comments

So I'm running gulp to process SASS, and I just updated this dependency from 14.1.0 to 15.0.0 and now when I try and run gulp I get an error.

An abridged version of my gulp CSS script that shows the error

import { src, dest } from 'gulp';
import gulpPostcss from 'gulp-postcss';
import postcssImport from 'postcss-import';
import { CONSTS } from './CONSTS';

const { CSS_DEST, NODE_ENV, SASS_SRC } = CONSTS;
const isDev = NODE_ENV !== 'production';
const gulpOptions = isDev ? { sourcemaps: true } : {};

function compileSass() {
  const processors = [postcssImport];

  return src(SASS_SRC + '/**/*.scss', gulpOptions)
    .pipe(gulpPostcss(processors))
    .pipe(dest(CSS_DEST, gulpOptions));
}

export { compileSass as sass };

Gives me the error:

/node_modules/postcss-import/index.js:45
      if (styles.source?.input?.file) {
                        ^

SyntaxError: Invalid or unexpected token
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    

I couldn't see any relevant bugs having been raised recently that relate to this and there's nothing I could see in the changelog that suggests I need to modify anything, so wondering if it's a bug?

scottlet avatar Sep 02 '22 05:09 scottlet

What's your Node.js version?

RyanZim avatar Sep 02 '22 20:09 RyanZim

It's the latest LTS (Node 16.17.0 now, was 16.16 when I initially tried it)

scottlet avatar Sep 07 '22 07:09 scottlet

That's strange, because the error you posted seems to indicate Node is failing to parse the optional chaining operator, but that should be fully supported by Node 16.

RyanZim avatar Sep 07 '22 15:09 RyanZim

Could it be because I’m running in via esm?Sent from my iPhoneOn 7. Sep 2022, at 17:31, Ryan Zimmerman @.***> wrote: That's strange, because the error you posted seems to indicate Node is failing to parse the optional chaining operator, but that should be fully supported by Node 16.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

scottlet avatar Sep 07 '22 17:09 scottlet

Shouldn't affect it. I just tested with ESM (just using the postcss API, not gulp), and it worked fine for me. At this point, trying to build a minimal test case is probably your best option.

RyanZim avatar Sep 07 '22 18:09 RyanZim

Closing for lack of reply.

RyanZim avatar Oct 11 '22 15:10 RyanZim