-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build!: generate cjs and type declarations #1572
Changes from all commits
e4c15c4
45f2ba5
0a3c65d
8a7c7a6
7d1b939
2d05ebd
90b865b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,24 @@ | |
"author": "CZI <edu-frontend-infra@chanzuckerberg.com>", | ||
"homepage": "https://github.com/chanzuckerberg/edu-design-system", | ||
"license": "MIT", | ||
"main": "lib/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./lib/index.js", | ||
"require": "./lib/index.cjs" | ||
}, | ||
"./index.css": { | ||
"import": "./lib/index.css", | ||
"require": "./lib/index.css" | ||
}, | ||
"./fonts.css": { | ||
"import": "./lib/tokens/fonts.css", | ||
"require": "./lib/tokens/fonts.css" | ||
}, | ||
Comment on lines
+13
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I short handed some of these styles exports so it's less unwieldy (i.e. |
||
"./tailwind.config": { | ||
"import": "./tailwind.config.ts" | ||
} | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ahuth Not sure if I'm using conditional exports right but seems that we have to explicitly state which files are allowed to be exported There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that's true. I kind of forgot that there was more than just the index.js files (such as fonts, css, tailwind, etc). Does this seem like it's too cumbersome, or is it okay? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine unless consumers want to use some of the internal components or the utils, which we haven't come across yet |
||
"types": "lib/index.d.ts", | ||
"sideEffects": [ | ||
"lib/tokens/css/variables.css", | ||
"lib/tokens/fonts.css" | ||
|
@@ -22,7 +39,7 @@ | |
}, | ||
"files": [ | ||
"/lib", | ||
"tailwind.config.js" | ||
"tailwind.config.mjs" | ||
], | ||
"scripts": { | ||
"build": "yarn build:clean && yarn build:tokens && yarn build:js && yarn copy-fonts-to-lib", | ||
|
@@ -90,8 +107,6 @@ | |
"react-popper": "^2.3.0", | ||
"react-portal": "^4.2.2" | ||
}, | ||
"entry": "lib/index.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what this line did? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea. Probs something in the BM template that doesn't do anything. |
||
"types": "lib/index.d.ts", | ||
"devDependencies": { | ||
"@chanzuckerberg/axe-storybook-testing": "^6.3.0", | ||
"@chanzuckerberg/eslint-config-edu-js": "^1.0.3", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,28 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'; | |
import typescript from '@rollup/plugin-typescript'; | ||
import postcss from 'rollup-plugin-postcss'; | ||
|
||
/** | ||
* @type {import('rollup').RollupOptions} | ||
*/ | ||
export default { | ||
input: 'src/index.ts', | ||
output: { | ||
dir: 'lib', | ||
format: 'es', | ||
preserveModules: true, | ||
preserveModulesRoot: 'src', | ||
}, | ||
output: [ | ||
{ | ||
dir: 'lib', | ||
format: 'es', | ||
preserveModules: true, | ||
preserveModulesRoot: 'src', | ||
sourcemap: true, | ||
}, | ||
{ | ||
dir: 'lib', | ||
format: 'cjs', | ||
preserveModules: true, | ||
preserveModulesRoot: 'src', | ||
sourcemap: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can turn sourcemaps off, not sure if anyone will take a look but also wouldn't hurt to have |
||
entryFileNames: '[name].cjs', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either way seems reasonable, so let's go with your preference. |
||
}, | ||
], | ||
/** | ||
* With the nodeResolve plugin, this marks all EDS node_modules as external, aka provided by the consumer. | ||
* Since EDS is not imported directly into a web <script>, package managers (such as npm or yarn) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig", | ||
"include": ["src/index.ts", "src/custom.d.ts"], | ||
"include": ["src/index.ts", "src/custom.d.ts"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,17 @@ | |
"allowJs": false, | ||
"allowSyntheticDefaultImports": true, | ||
"declaration": true, | ||
"declarationDir": "lib", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"jsx": "react", | ||
"lib": ["es5", "es6", "dom"], | ||
"moduleResolution": "node", | ||
"noUnusedLocals": true, | ||
"outDir": "lib", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer using |
||
"resolveJsonModule": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"target": "es6" | ||
"target": "es2018" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Target is being bumped to remove |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested failing with
es2017
https://github.com/chanzuckerberg/edu-design-system/actions/runs/4600946862/jobs/8128192461