Skip to content
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

Metalsmith 2.5 Roadmap #365

Closed
8 tasks done
webketje opened this issue Jan 31, 2022 · 1 comment
Closed
8 tasks done

Metalsmith 2.5 Roadmap #365

webketje opened this issue Jan 31, 2022 · 1 comment

Comments

@webketje
Copy link
Member

webketje commented Jan 31, 2022

This issue is meant to group & provide an overview of what features will be in release 2.5

@webketje webketje pinned this issue Jan 31, 2022
@webketje
Copy link
Member Author

webketje commented Mar 1, 2022

Regarding ESM support:
Tested on a local branch, and the conclusion is that metalsmith and its core plugins already support ESM because they only use a default export. NodeJS "automagically" assigns module.exports to export default when running in ESM mode.

There are some traps that are useful to note for future developments:

  • ES modules have no native loader for importing *.json files, so doing something like require('../package.json').version will make a CJS module incompatible with ES modules, unless a createRequire is done. No .json's will be required internally, so this is ok
  • Named exports are not supported. If for example static methods are added to Metalsmith they cannot be imported as import { staticMethod } from 'metalsmith', only by destructuring the default export. No static methods will be added for 2.x, so this is ok. Even if they are added, the benefits of named imports are small (because Metalsmith is small and named exports would have a negligible impact for those of us using bundling)

Tests using a linked metalsmith package on diffferent Node versions with NVM resulted in inconvenient results for either the user or the maintainer:

  • specifying a package.json exports property is a semver-major breaking change (for v3.x)
  • specifying a shallow index.mjs wrapper and declaring"type": "commonjs" was inconvenient for ESM users as you needed to import from 'metalsmith/index.mjs
  • declaring "type": "module" would be a lie
  • unit testing with mocha was more of a pain

In conclusion, I will replace the wording "ESM support" to "Basic ESM support", and hold off major changes for 3.x

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

No branches or pull requests

1 participant