Skip to content

Commit

Permalink
fix(cli): change moduleResolution to catch missing file extensions wh…
Browse files Browse the repository at this point in the history
…ich cause trouble downstream (#2909)
  • Loading branch information
unekinn authored Dec 16, 2024
1 parent 1297ddc commit 9b6401b
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-phones-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@digdir/designsystemet": patch
---

Fix crash when running @digdir/designsystemet CLI due to differences in module resolution when used as a package
2 changes: 1 addition & 1 deletion packages/cli/src/colors/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chroma from 'chroma-js';
import { Hsluv } from 'hsluv';
import type { ColorNumber, CssColor } from './types';
import type { ColorNumber, CssColor } from './types.js';

/**
* Converts a HEX color '#xxxxxx' into a CSS HSL string 'hsl(x,x,x)'
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './colors';
export * from './tokens';
export * from './colors/index.js';
export * from './tokens/index.js';
2 changes: 1 addition & 1 deletion packages/cli/src/tokens/build/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Config as StyleDictionaryConfig, TransformedToken } from 'style-dictionary/types';
import type { GetStyleDictionaryConfig } from './configs';
import type { GetStyleDictionaryConfig } from './configs.js';

export const colorCategories = {
main: 'main',
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/tokens/build/utils/entryfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk';
import glob from 'fast-glob';
import fs from 'fs-extra';
import * as R from 'ramda';
import { writeFile } from '../../utils';
import { writeFile } from '../../utils.js';

/**
* Defines a sort order for the sections of the entry CSS file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import chalk from 'chalk';
import { kebabCase } from 'change-case';
import * as R from 'ramda';
import { buildOptions } from '../../build.js';
import type { ThemeDimension, ThemePermutation } from '../types';
import type { ThemeDimension, ThemePermutation } from '../types.js';

/**
* Find the theme permutations that are relevant for the given theme dimensions.
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/tokens/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { type CreateTokensOptions, createTokens, colorCliOptions } from './create';
export { type CreateTokensOptions, createTokens, colorCliOptions } from './create.js';
2 changes: 1 addition & 1 deletion packages/cli/src/tokens/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import originalColorCategoryJson from '../../../../design-tokens/semantic/modes/
type: 'json',
};
import originalThemeJson from '../../../../design-tokens/themes/theme.json' with { type: 'json' };
import { stringify } from './write';
import { stringify } from './write.js';

const DIRNAME: string = import.meta.dirname || __dirname;

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/tokens/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CssColor } from '../colors/types';
import type { CssColor } from '../colors/types.js';

export type Token = { $value: string; $type: string };
export type Tokens1ary = Record<string, Token>;
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"noEmit": false,
"esModuleInterop": true,
"resolveJsonModule": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"sourceMap": false,
"incremental": false
},
Expand Down

0 comments on commit 9b6401b

Please sign in to comment.