Skip to content

Commit

Permalink
fix(package): add commonjs exports and exports config (#27)
Browse files Browse the repository at this point in the history
* fix(package): add commonjs exports and exports config

* fix: file configs and exports
  • Loading branch information
adamdehaven authored Jun 29, 2023
1 parent df8df1e commit 05e3ad8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
29 changes: 23 additions & 6 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ platforms.css = {
],
files: [
{
destination: 'variables.css',
format: 'css/variables',
destination: 'variables.css',
options: {
selector: ':root', // You can override the default selector; may be necessary for consumers (e.g. Kongponents)
},
Expand Down Expand Up @@ -115,15 +115,15 @@ platforms.scss = {
files: [
// SCSS variables
{
destination: '_variables.scss',
format: 'scss/variables',
destination: '_variables.scss',
// Exclude alias tokens and asset tokens compiled in a separate file
filter: (token) => token.isSource === true && token.attributes.category !== 'asset',
},
// SCSS CSS variables mixin
{
destination: '_mixins.scss',
format: 'css/variables/custom/sass/mixin',
destination: '_mixins.scss',
// Exclude alias tokens and asset tokens compiled in a separate file
filter: (token) => token.isSource === true && token.attributes.category !== 'asset',
},
Expand All @@ -148,17 +148,34 @@ platforms.javascript = {
'color/css',
],
files: [
// JavaScript constants
// JavaScript ES constants
{
destination: 'index.js',
format: 'javascript/es6',
destination: 'index.js',
// Exclude alias tokens and asset tokens compiled in a separate file
filter: (token) => token.isSource === true && token.attributes.category !== 'asset',
},
// Constants TypeScript types
{
destination: 'index.d.ts',
format: 'typescript/es6-declarations',
destination: 'index.d.ts',
options: {
outputStringLiterals: true,
},
// Exclude alias tokens and asset tokens compiled in a separate file
filter: (token) => token.isSource === true && token.attributes.category !== 'asset',
},
// JavaScript CommonJS
{
format: 'javascript/module-flat',
destination: 'cjs/index.cjs',
// Exclude alias tokens and asset tokens compiled in a separate file
filter: (token) => token.isSource === true && token.attributes.category !== 'asset',
},
// CommonJS types
{
format: 'typescript/module-declarations',
destination: 'cjs/index.d.ts',
options: {
outputStringLiterals: true,
},
Expand Down
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@
],
"types": "dist/tokens/js/index.d.ts",
"exports": {
".": "./dist/tokens/js/index.js",
".": {
"import": {
"default": "./dist/tokens/js/index.js",
"types": "./dist/tokens/js/index.d.ts"
},
"require": {
"default": "./dist/tokens/js/cjs/index.cjs",
"types": "./dist/tokens/js/cjs/index.d.ts"
}
},
"./package.json": "./package.json",
"./tokens/*": "./dist/tokens/*"
},
Expand Down

0 comments on commit 05e3ad8

Please sign in to comment.