Any reliances on "require()" to import JSON files are now using JSON.parse(fs.readFileSync()) instead. For JS files, only ESM is supported, through dynamic imports. Due to dynamic imports being async in nature, some of the APIs have already changed to becoming async and returning promises.
Some deprecated stuff, I already removed in this PR, because they tended to be features that were a bit annoying to convert to browser-compatible ESM.
Some formatting changes still, sadly, didn't catch everything in the previous PR
Changing var to const or let
Changing the templates files to be ES Modules, so they can be more easily imported in both NodeJS and the Browser too.
TODOs for next PR, since at Tokens Studio we could really use an early, unstable, prerelease of this change, and the PR is big enough as is:
Lots of manual smoke testing in both browser and node environment to find issues early
Make the tests work again, to spot regressions, but we should test in a headless browser to spot browser incompatibilities, so we'll have to switch test runner
Remove leftover references to properties/allProperties, now is tokens/allTokens
Breaking changes list
CommonJS format Configs or Tokens are no longer supported
StyleDictionary.extend() is now async, so returns Promise<StyleDictionary.Core> instead of StyleDictionary.Core
allProperties/properties was deprecated, is now removed from StyleDictionary.Core in some places (although lots of leftovers still remain in the codebase, to be removed).
Templates/registerTemplate were deprecated in favor of formats, now templates is removed.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description of changes: Converts the entire repository to:
Apart from the ESM format changes, the changes you will encounter:
JSON.parse(fs.readFileSync())
instead. For JS files, only ESM is supported, through dynamic imports. Due to dynamic imports being async in nature, some of the APIs have already changed to becoming async and returning promises.var
toconst
orlet
TODOs for next PR, since at Tokens Studio we could really use an early, unstable, prerelease of this change, and the PR is big enough as is:
Breaking changes list
Promise<StyleDictionary.Core>
instead ofStyleDictionary.Core
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.