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
feat(esm): migrate this package to a pure ESM #252
Conversation
BREAKING CHANGE: Please run node 12.20 or higher BREAKING CHANGE: This package is now a pure esm, please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)
Seems to work 👍 Technically a breaking change for people requiring from decktape directly: |
|
||
// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart | ||
if (!String.prototype.padStart) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String padding is supported in all LTS versions of node now
"fonteditor-core": "2.1.10", | ||
"pdf-lib": "1.17.1", | ||
"puppeteer": "18.2.1", | ||
"puppeteer-core": "18.2.1", | ||
"urijs": "1.19.11" | ||
}, | ||
"engines": { | ||
"node": ">=12.0.0" | ||
"node": ">=12.20" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the minimal version for ESM
@@ -226,6 +218,18 @@ process.on('unhandledRejection', error => { | |||
}); | |||
|
|||
(async () => { | |||
const plugins = await loadAvailablePlugins(path.join(path.dirname(fileURLToPath(import.meta.url)), 'plugins')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loading plugins could not be done the same way dynamically without an await
. I decided to move this inside the anonymous async
function.
fs.accessSync(pdfDir, fs.constants.F_OK); | ||
} catch { | ||
fs.mkdirSync(pdfDir, { recursive: true }); | ||
async function writePdf(filename, pdf) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved all these functions inside the anonymous async
function, because most of them seem to use the options
that are now parsed at the top of the anonymous function, just after loading plugins. (no longer a global variable)
|
||
const plugins = loadAvailablePlugins(path.join(path.dirname(__filename), 'plugins')); | ||
import chalk from 'chalk'; | ||
import chalkTemplate from 'chalk-template'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chalk v5 seems to have split out its tagged template literal functionality into a separate package 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's awesome! I've given it a try and identified a couple of small specific issues. Let's merge this, and I'll work on fixing them. Maybe I'll bump the major version in the next release so it's clear that's a breaking change, even if Decktape is more a CLI than a library that is depended on.
BREAKING CHANGE: Please run node 12.20 or higher
BREAKING CHANGE: This package is now a pure esm, please read this