Skip to content

Commit

Permalink
build: add sourcemaps and add declaration back to tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin Lee committed Mar 31, 2023
1 parent e4c15c4 commit 22dab1b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"build:js": "rollup --config",
"build:storybook": "build-storybook -o storybook-static -s src/design-tokens/tier-1-definitions/fonts",
"build:styles": "postcss \"src/components/**/*.css\" --dir lib/ --base src/ --verbose",
"build:types": "tsc --project tsconfig.build.json --declaration --emitDeclarationOnly --declarationDir \"lib/types\"",
"build:types": "tsc --project tsconfig.build.json --emitDeclarationOnly",
"chromatic": "chromatic",
"copy-fonts-to-lib": "copyfiles -u 3 src/design-tokens/tier-1-definitions/fonts.css src/design-tokens/tier-1-definitions/fonts/**/* lib/tokens",
"copy-tokens-to-lib": "copyfiles -u 2 src/tokens-dist/**/* lib/tokens",
Expand Down Expand Up @@ -64,7 +64,7 @@
"plop:recipe": "plop recipe",
"test": "jest",
"test:ci": "yarn run test --ci --coverage && cat ./coverage/lcov.info | codecov",
"types": "tsc"
"types": "tsc --noEmit"
},
"size-limit": [
{
Expand Down
11 changes: 11 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ export default {
format: 'es',
preserveModules: true,
preserveModulesRoot: 'src',
sourcemap: true,
},
{
dir: 'lib/cjs',
format: 'cjs',
preserveModules: true,
preserveModulesRoot: 'src',
sourcemap: true,
},
],
/**
Expand All @@ -36,6 +38,15 @@ export default {
}),
typescript({
tsconfig: 'tsconfig.build.json',
compilerOptions: {
/**
* Rollup wants declarations in the same directory as the output folder,
* but since we ship both cjs and esm in separate folders, this will throw an error.
* Declarations are hence built separately using tsc into lib/types
*/
declaration: false,
declarationDir: undefined,
},
}),
],
};
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This brings the style tokens that are css custom variables into the built stylesheet so only one stylesheet for EDS has to be imported.
import './tokens-dist/css/variables.css';

export { default as Accordion } from './components/Accordion';
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationDir": "lib/types",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
Expand Down

0 comments on commit 22dab1b

Please sign in to comment.