Skip to content

Commit dd2e42b

Browse files
committed
added components to index
1 parent 662e5f4 commit dd2e42b

File tree

6 files changed

+1015
-37
lines changed

6 files changed

+1015
-37
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@
2323
},
2424
"[typescriptreact]": {
2525
"editor.defaultFormatter": "vscode.typescript-language-features"
26+
},
27+
"[javascript]": {
28+
"editor.defaultFormatter": "vscode.typescript-language-features"
2629
}
2730
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@
5454
"rollup": "^4.13.0",
5555
"rollup-plugin-dts": "^6.1.0",
5656
"rollup-plugin-peer-deps-external": "^2.2.4",
57+
"rollup-plugin-postcss": "^4.0.2",
5758
"rollup-plugin-preserve-directives": "^0.4.0",
5859
"rollup-plugin-tsconfig-paths": "^1.5.2",
59-
"sass": "^1.53.0",
60+
"sass": "^1.91.0",
6061
"storybook": "^9.1.3",
6162
"tslib": "^2.8.1",
6263
"typescript": "5.3.3",

rollup.config.mjs

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,84 +6,101 @@ import external from 'rollup-plugin-peer-deps-external';
66
import { dts } from 'rollup-plugin-dts';
77
import tsPaths from 'rollup-plugin-tsconfig-paths';
88
import preserveDirectives from 'rollup-plugin-preserve-directives';
9+
import postcss from 'rollup-plugin-postcss';
910

1011
import tsBuildConfig from './bundle-base.tsconfig.json' assert { type: 'json' };
1112
import packageJson from './package.json' assert { type: 'json' };
1213

13-
// suppresses warnings printed to console as part of bundling components with directives present.
1414
const onWarnSuppression = {
1515
onwarn(warning, warn) {
1616
if (warning.code === 'MODULE_LEVEL_DIRECTIVE' && warning.message.includes(`"use client"`)) return;
1717
warn(warning);
1818
},
1919
};
2020

21-
// Keep react 19 out of the bundle
22-
const externals = ['react', 'react-dom', 'react/jsx-runtime'];
23-
2421
const commonPlugins = [
25-
external(), // auto-externalize peer deps
26-
tsPaths(), // respect tsconfig paths in source
22+
external(),
23+
tsPaths(),
2724
resolve({ extensions: ['.mjs', '.js', '.ts', '.tsx'] }),
2825
commonjs(),
26+
// ⬇️ compile SCSS → CSS for any `import './file.scss'`
27+
postcss({
28+
extract: true, // or a filename like 'styles.css'
29+
modules: false,
30+
minimize: false,
31+
use: { sass: { quietDeps: true } }, // uses Dart Sass
32+
includePaths: ['node_modules'], // lets you @use "nhsuk-frontend/..." cleanly
33+
}),
2934
];
3035

36+
// JS-only version of preserveDirectives
37+
const jsOnlyPreserveDirectives = preserveDirectives({
38+
include: ['**/*.{js,jsx,ts,tsx,mjs,cjs}'],
39+
exclude: ['**/*.{css,scss,sass,less,styl}'],
40+
});
41+
3142
export default [
32-
// CJS (single file)
43+
// cjs export
3344
{
3445
input: 'src/index.ts',
35-
external: externals,
36-
output: [
37-
{
38-
file: packageJson.main, // e.g. dist/cjs/index.js
39-
format: 'cjs',
40-
sourcemap: true,
41-
},
42-
],
46+
output: [{ file: packageJson.main, format: 'cjs', sourcemap: true }],
4347
plugins: [
4448
...commonPlugins,
4549
typescript({
46-
// IMPORTANT: dedicated build tsconfig (noEmit, no jest/node types)
47-
tsconfig: './tsconfig.build.json',
50+
tsconfig: 'bundle-base.tsconfig.json',
51+
compilerOptions: { declaration: false },
4852
}),
49-
preserveDirectives(), // keep "use client" etc.
50-
terser({ compress: { directives: false } }),
53+
terser(),
5154
],
5255
...onWarnSuppression,
5356
},
5457

55-
// ESM (single file)
58+
// esm export
5659
{
5760
input: 'src/index.ts',
58-
external: externals,
5961
output: [
6062
{
61-
file: packageJson.module, // e.g. dist/esm/index.js
63+
dir: packageJson.module,
6264
format: 'esm',
6365
sourcemap: true,
66+
preserveModules: true,
67+
preserveModulesRoot: 'src',
6468
},
6569
],
6670
plugins: [
6771
...commonPlugins,
6872
typescript({
69-
tsconfig: './tsconfig.build.json',
73+
tsconfig: 'bundle-base.tsconfig.json',
74+
compilerOptions: {
75+
declaration: false, // don’t emit .d.ts here
76+
emitDeclarationOnly: false,
77+
outDir: undefined, // let Rollup handle files
78+
},
7079
}),
71-
preserveDirectives(),
80+
jsOnlyPreserveDirectives, // ⬅️ don't touch .scss
7281
terser({ compress: { directives: false } }),
7382
],
7483
...onWarnSuppression,
7584
},
7685

77-
// Type definitions (bundled .d.ts)
86+
// type bundling
87+
// type bundling
7888
{
7989
input: 'src/index.ts',
80-
external: externals,
8190
output: [{ file: 'dist/index.d.ts', format: 'esm' }],
91+
92+
// ⬅️ Ignore any style imports during .d.ts bundling
93+
external: [/\.s?css$/i, /\.less$/i, /\.styl(us)?$/i],
94+
8295
plugins: [
8396
dts({
84-
// carry over path mapping if you have any
85-
compilerOptions: { paths: tsBuildConfig?.compilerOptions?.paths ?? {} },
97+
respectExternal: true, // ⬅️ key: don't inline externals (like the styles we exclude)
98+
compilerOptions: {
99+
// carry over paths if you use them
100+
paths: tsBuildConfig.compilerOptions.paths,
101+
},
86102
}),
87103
],
88-
},
104+
}
105+
89106
];

src/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,14 @@ export { default as ReadingWidth } from './components/utils/ReadingWidth';
6262
export { default as FormGroup } from './components/utils/FormGroup';
6363

6464
export { default as ReviewDate } from './patterns/review-date';
65+
66+
export { default as AccordionMenu } from './components/accordion-menu';
67+
export { default as HeaderWithLogo} from './components/header-with-logo'
68+
69+
export { default as RibbonLink } from './components/ribbon-link';
70+
export { default as SubNavigation } from './components/sub-navigation';
71+
// export { default as TabSet } from './components/tab-set';
72+
export { default as Timeline } from './components/timeline';
73+
export { default as Tooltip } from './components/tooltip';
74+
export { WarningIcon } from './components/icons';
75+

src/types/style-modules.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare module '*.scss';
2+
declare module '*.css';

0 commit comments

Comments
 (0)