Skip to content
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

fix types according to @arethetypeswrong/cli #314

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ jobs:
- run: npm run build
# Verify built artefacts
- run: npm run test
# Check that the exported types resolves correctly
- run: npm run check-exports
8 changes: 8 additions & 0 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ function clean (groupNames) {
fse.removeSync(path.join(npmPath, `${bundleName}.js`))
fse.removeSync(path.join(npmPath, `${bundleName}.mjs`))
fse.removeSync(path.join(npmPath, `${bundleName}.d.ts`))
fse.removeSync(path.join(npmPath, `${bundleName}.d.mts`))
// Remove old npm jsx content
fse.removeSync(path.join(npmJsxFolder, npmPath, `${bundleName}.js`))
fse.removeSync(path.join(npmJsxFolder, npmPath, `${bundleName}.mjs`))
fse.removeSync(path.join(npmJsxFolder, npmPath, `${bundleName}.d.ts`))
fse.removeSync(path.join(npmJsxFolder, npmPath, `${bundleName}.d.mts`))

// Ensure npm folders exist (for icons it's '' which is falsy)
if (npmPath) fse.mkdirsSync(npmPath)
Expand Down Expand Up @@ -140,11 +142,13 @@ function buildIcons (groupName) {
fse.writeFileSync(path.join(npmPath, `${bundleName}.js`), icons.cjs)
fse.writeFileSync(path.join(npmPath, `${bundleName}.mjs`), icons.esm)
fse.writeFileSync(path.join(npmPath, `${bundleName}.d.ts`), icons.dtsLiteral)
fse.writeFileSync(path.join(npmPath, `${bundleName}.d.mts`), icons.dtsLiteral)

// Generate jsx and mjsx with types for icons and logos
fse.writeFileSync(path.join(npmJsxFolder, npmPath, `${bundleName}.js`), icons.cjsx)
fse.writeFileSync(path.join(npmJsxFolder, npmPath, `${bundleName}.mjs`), icons.esmx)
fse.writeFileSync(path.join(npmJsxFolder, npmPath, `${bundleName}.d.ts`), icons.dtsx)
fse.writeFileSync(path.join(npmJsxFolder, npmPath, `${bundleName}.d.mts`), icons.dtsx)

// Generate js/jsx artefacts for logo/large -files
if (groupName === 'logo') {
Expand All @@ -162,20 +166,24 @@ function buildIcons (groupName) {
fse.removeSync(path.join(npmLargePath, `${largeBundleName}.js`))
fse.removeSync(path.join(npmLargePath, `${largeBundleName}.mjs`))
fse.removeSync(path.join(npmLargePath, `${largeBundleName}.d.ts`))
fse.removeSync(path.join(npmLargePath, `${largeBundleName}.d.mts`))
// Remove old npm jsx content
fse.removeSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.js`))
fse.removeSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.mjs`))
fse.removeSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.d.ts`))
fse.removeSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.d.mts`))

// Generate js and mjs with types for icons and logos
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.js`), largeIcons.cjs)
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.mjs`), largeIcons.esm)
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.d.ts`), largeIcons.dtsLiteral)
fse.writeFileSync(path.join(npmLargePath, `${largeBundleName}.d.mts`), largeIcons.dtsLiteral)

// Generate jsx and mjsx with types for icons and logos
fse.writeFileSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.js`), largeIcons.cjsx)
fse.writeFileSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.mjs`), largeIcons.esmx)
fse.writeFileSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.d.ts`), largeIcons.dtsx)
fse.writeFileSync(path.join(npmJsxFolder, npmLargePath, `${largeBundleName}.d.mts`), largeIcons.dtsx)
}
} catch (error) {
console.error(`Failed to generate large js files for ${groupName} with error `, error)
Expand Down
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 85 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,110 @@
"./core-icons-iife.js",
"./core-icons.js",
"./core-icons.mjs",
"./core-icons.d.ts"
"./core-icons.d.ts",
"./core-icons.d.mts"
],
"exports": {
".": {
"types": "./core-icons.d.ts",
"require": "./core-icons.js",
"import": "./core-icons.mjs",
"require": {
"default": "./core-icons.js",
"types": "./core-icons.d.ts"
},
"import": {
"default": "./core-icons.mjs",
"types": "./core-icons.d.mts"
},
"browser": "./core-icons-iife.js"
},
"./logo": {
"types": "./logo/core-icons-logo.d.ts",
"require": "./logo/core-icons-logo.js",
"import": "./logo/core-icons-logo.mjs"
"require": {
"default": "./logo/core-icons-logo.js",
"types": "./logo/core-icons-logo.d.ts"
},
"import": {
"default": "./logo/core-icons-logo.mjs",
"types": "./logo/core-icons-logo.d.mts"
}
},
"./logo/large": {
"types": "./logo/large/core-icons-logo-large.d.ts",
"require": "./logo/large/core-icons-logo-large.js",
"import": "./logo/large/core-icons-logo-large.mjs"
"require": {
"default": "./logo/large/core-icons-logo-large.js",
"types": "./logo/large/core-icons-logo-large.d.ts"
},
"import": {
"default": "./logo/large/core-icons-logo-large.mjs",
"types": "./logo/large/core-icons-logo-large.d.mts"
}
},
"./expressive": {
"types": "./expressive/core-icons-expressive.d.ts",
"require": "./expressive/core-icons-expressive.js",
"import": "./expressive/core-icons-expressive.mjs"
"require": {
"default": "./expressive/core-icons-expressive.js",
"types": "./expressive/core-icons-expressive.d.ts"
},
"import": {
"default": "./expressive/core-icons-expressive.mjs",
"types": "./expressive/core-icons-expressive.d.mts"
}
},
"./preview": {
"types": "./preview/core-icons-preview.d.ts",
"require": "./preview/core-icons-preview.js",
"import": "./preview/core-icons-preview.mjs"
"require": {
"default": "./preview/core-icons-preview.js",
"types": "./preview/core-icons-preview.d.ts"
},
"import": {
"default": "./preview/core-icons-preview.mjs",
"types": "./preview/core-icons-preview.d.mts"
}
},
"./jsx": {
"types": "./jsx/core-icons.d.ts",
"require": "./jsx/core-icons.js",
"import": "./jsx/core-icons.mjs"
"require": {
"default": "./jsx/core-icons.js",
"types": "./jsx/core-icons.d.ts"
},
"import": {
"default": "./jsx/core-icons.mjs",
"types": "./jsx/core-icons.d.mts"
}
},
"./jsx/logo": {
"types": "./jsx/logo/core-icons-logo.d.ts",
"require": "./jsx/logo/core-icons-logo.js",
"import": "./jsx/logo/core-icons-logo.mjs"
"require": {
"default": "./jsx/logo/core-icons-logo.js",
"types": "./jsx/logo/core-icons-logo.d.ts"
},
"import": {
"default": "./jsx/logo/core-icons-logo.mjs",
"types": "./jsx/logo/core-icons-logo.d.mts"
}
},
"./jsx/logo/large": {
"types": "./jsx/logo/large/core-icons-logo-large.d.ts",
"require": "./jsx/logo/large/core-icons-logo-large.js",
"import": "./jsx/logo/large/core-icons-logo-large.mjs"
"require": {
"default": "./jsx/logo/large/core-icons-logo-large.js",
"types": "./jsx/logo/large/core-icons-logo-large.d.ts"
},
"import": {
"default": "./jsx/logo/large/core-icons-logo-large.mjs",
"types": "./jsx/logo/large/core-icons-logo-large.d.mts"
}
},
"./jsx/expressive": {
"types": "./jsx/expressive/core-icons-expressive.d.ts",
"require": "./jsx/expressive/core-icons-expressive.js",
"import": "./jsx/expressive/core-icons-expressive.mjs"
"require": {
"default": "./jsx/expressive/core-icons-expressive.js",
"types": "./jsx/expressive/core-icons-expressive.d.ts"
},
"import": {
"default": "./jsx/expressive/core-icons-expressive.mjs",
"types": "./jsx/expressive/core-icons-expressive.d.mts"
}
},
"./jsx/preview": {
"types": "./jsx/preview/core-icons-preview.d.ts",
"require": "./jsx/preview/core-icons-preview.js",
"import": "./jsx/preview/core-icons-preview.mjs"
"require": {
"default": "./jsx/preview/core-icons-preview.js",
"types": "./jsx/preview/core-icons-preview.d.ts"
},
"import": {
"default": "./jsx/preview/core-icons-preview.mjs",
"types": "./jsx/preview/core-icons-preview.d.mts"
}
}
},
"scripts": {
Expand All @@ -83,10 +134,11 @@
"preversion": "npm run test",
"postversion": "npm run build && git push && git push --tags && npm publish",
"start": "npm run build:watch & http-server ./static -o -p 10001 -c-1",
"static-publish": "npm run build && static-publish --directory=static --account=nrk-core --latest --major"
"static-publish": "npm run build && static-publish --directory=static --account=nrk-core --latest --major",
"check-exports": "attw --pack ."
},
"devDependencies": {
"@arethetypeswrong/cli": "0.15.4",
"@arethetypeswrong/cli": "^0.15.4",
"@nrk/svg-to-js": "3.1.0",
"@types/fs-extra": "11.0.4",
"archiver": "6.0.1",
Expand Down
Loading