Skip to content

Commit

Permalink
🔥 Avoid exporting 'static' tokens until needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh committed Feb 5, 2025
1 parent 75d2f7a commit 1c31997
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 56 deletions.
98 changes: 50 additions & 48 deletions @navikt/core/tokens/darkside/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { bundle } from "lightningcss";
import StyleDictionary from "style-dictionary";
import {
formatCJS,
formatCJSStatic,
formatES6,
formatES6Static,
formatLESS,
formatSCSS,
transformCSS,
Expand Down Expand Up @@ -44,6 +42,10 @@ const filenames = {
* - Shadows
* - Typography
* - Breakpoints
*
*
* @note We currrently avoid exporting 'static' tokens, as this step might not be needed.
* In the current implementation we don't account for light and dark mode for static exports. This will need to be added if we want static exports.
*/
const SDictionaryLightMode = new StyleDictionary({
tokens: lightModeTokens(),
Expand Down Expand Up @@ -143,24 +145,24 @@ const SDDictionaryNonCSSFormats = new StyleDictionary({
},
],
},
jsStatic: {
transformGroup: "js",
buildPath: `${DARKSIDE_DIST}static/`,
files: [
{
destination: "tokens.js",
format: "format-ES6-static",
},
{
destination: "tokens-cjs.js",
format: "format-CJS-static",
},
{
destination: "tokens.d.ts",
format: "format-ES6-static",
},
],
},
// jsStatic: {
// transformGroup: "js",
// buildPath: `${DARKSIDE_DIST}static/`,
// files: [
// {
// destination: "tokens.js",
// format: "format-ES6-static",
// },
// {
// destination: "tokens-cjs.js",
// format: "format-CJS-static",
// },
// {
// destination: "tokens.d.ts",
// format: "format-ES6-static",
// },
// ],
// },
scss: {
transformGroup: "scss",
buildPath: DARKSIDE_DIST,
Expand All @@ -172,16 +174,16 @@ const SDDictionaryNonCSSFormats = new StyleDictionary({
},
],
},
scssStatic: {
transformGroup: "scss",
buildPath: `${DARKSIDE_DIST}static/`,
files: [
{
destination: "tokens.scss",
format: "scss/variables",
},
],
},
// scssStatic: {
// transformGroup: "scss",
// buildPath: `${DARKSIDE_DIST}static/`,
// files: [
// {
// destination: "tokens.scss",
// format: "scss/variables",
// },
// ],
// },
less: {
transformGroup: "less",
buildPath: DARKSIDE_DIST,
Expand All @@ -192,16 +194,16 @@ const SDDictionaryNonCSSFormats = new StyleDictionary({
},
],
},
lessStatic: {
transformGroup: "less",
buildPath: `${DARKSIDE_DIST}static/`,
files: [
{
destination: "tokens.less",
format: "less/variables",
},
],
},
// lessStatic: {
// transformGroup: "less",
// buildPath: `${DARKSIDE_DIST}static/`,
// files: [
// {
// destination: "tokens.less",
// format: "less/variables",
// },
// ],
// },
},
});

Expand All @@ -227,20 +229,20 @@ const main = async () => {
format: formatES6,
});

SDDictionaryNonCSSFormats.registerFormat({
name: "format-ES6-static",
format: formatES6Static,
});
// SDDictionaryNonCSSFormats.registerFormat({
// name: "format-ES6-static",
// format: formatES6Static,
// });

SDDictionaryNonCSSFormats.registerFormat({
name: "format-CJS",
format: formatCJS,
});

SDDictionaryNonCSSFormats.registerFormat({
name: "format-CJS-static",
format: formatCJSStatic,
});
// SDDictionaryNonCSSFormats.registerFormat({
// name: "format-CJS-static",
// format: formatCJSStatic,
// });

SDDictionaryNonCSSFormats.registerFormat({
name: "format-SCSS",
Expand Down
9 changes: 1 addition & 8 deletions @navikt/core/tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@
"require": "./dist/darkside/tokens-cjs.js"
},
"./darkside-scss": "./dist/darkside/tokens.scss",
"./darkside-less": "./dist/darkside/tokens.less",
"./darkside-js-static": {
"types": "./dist/darkside/static/tokens.d.ts",
"import": "./dist/darkside/static/tokens.js",
"require": "./dist/darkside/static/tokens-cjs.js"
},
"./darkside-scss-static": "./dist/darkside/static/tokens.scss",
"./darkside-less-static": "./dist/darkside/static/tokens.less"
"./darkside-less": "./dist/darkside/tokens.less"
}
}

0 comments on commit 1c31997

Please sign in to comment.