Skip to content

Support loading ECMAScript modules, but drop sync API (#230)#234

Merged
ai merged 1 commit intopostcss:mainfrom
michael42:esm
May 23, 2022
Merged

Support loading ECMAScript modules, but drop sync API (#230)#234
ai merged 1 commit intopostcss:mainfrom
michael42:esm

Conversation

@michael42
Copy link
Copy Markdown
Contributor

@michael42 michael42 commented Mar 29, 2022

Notable Changes

This PR implements support for .mjs config files (and .js config files within "type": "modules" projects). To support that without much hassle, support for synchronously loading configs is dropped, as ECMAScript Modules are loaded inherently async.

Commit Message Summary (CHANGELOG)

commit message body...

Type

  • CI
  • Fix
  • Perf
  • Docs
  • Test
  • Chore
  • Style
  • Build
  • Feature
  • Refactor

SemVer

  • Fix (:label: Patch)
  • Feature (:label: Minor)
  • Breaking Change (:label: Major)

Issues

  • Fixes #230

Checklist

  • Lint and unit tests pass with my changes
  • I have added tests that prove my fix is effective/works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes are merged and published in downstream modules

src/index.js Outdated
}
}

// prefers import, which won't work in sync mode
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it better to check Node.js version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think feature detection is a bit cleaner, as it might support different runtimes (like Deno). Although in this case, the feature-detection is quite Node-specific and I don't find documentation for it in the Node 10 docs.

@michael42 michael42 force-pushed the esm branch 2 times, most recently from 3475c1c to 0a96011 Compare April 6, 2022 19:36
@michael42 michael42 marked this pull request as ready for review April 6, 2022 19:52
@michael42 michael42 force-pushed the esm branch 2 times, most recently from c8a7e26 to fac2e53 Compare April 6, 2022 20:02
@michael42 michael42 changed the title Try out support for ECMAScript modules (#230) Support loading ECMAScript modules, but drop sync API (#230) Apr 6, 2022
@ai
Copy link
Copy Markdown
Member

ai commented Apr 10, 2022

I will put this task on a little hold until Node.js 12 EOL

@binyamin
Copy link
Copy Markdown

binyamin commented May 4, 2022

I will put this task on a little hold until Node.js 12 EOL

@ai That time has come. See the release chart.

@ai ai merged commit 1cffdc4 into postcss:main May 23, 2022
@ai
Copy link
Copy Markdown
Member

ai commented May 23, 2022

Released in 4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants