sindresorhus / gulp-autoprefixer

Prefix CSS
MIT License
692 stars 50 forks source link

Maybe should export for cjs and esm respectively #121

Closed qmhc closed 9 months ago

qmhc commented 9 months ago

When I upgrade from v8 to v9, it broken the gulp build.

I write gulpfile.ts in TypeScript and use sucrase/register/ts to transform the file with command gulp --require sucrase/register/ts.

Run the command with v8, all things work well.

But with v9, an error will be occurred:

[10:03:28] Requiring external module ts-node/register
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for E:\my-project\gulpfile.ts
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:124:36)
    at defaultLoad (node:internal/modules/esm/load:89:20)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:603:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:64:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

In my gulpfile.ts, I use this plugin like the below:

import { resolve } from 'node:path'
import { dest, src } from 'gulp'
import gulpSass from 'gulp-sass'
import dartSass from 'sass'
import autoprefixer from 'gulp-autoprefixer'
import cleanCSS from 'gulp-clean-css'

function buildStyle() {
  const sass = gulpSass(dartSass)

  return src(resolve(__dirname, 'style/*.scss'))
    .pipe(sass.sync())
    .pipe(autoprefixer({ cascade: false }))
    .pipe(cleanCSS())
    .pipe(dest(cssDir))
}
sindresorhus commented 9 months ago

From the release notes:

qmhc commented 9 months ago

Well, my workspace is using "type": "module" and Node@18. Is anything I missed that to make glupfile work in both TypeScript and ESM? (I will get an error Cannot use 'import.meta' outside a module)