Skip to content
Merged
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
15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
{
"name": "@atom-learning/icons",
"main": "dist/index.cjs.js",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"version": "1.22.0",
"version": "1.23.0",
"description": "",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"files": [
"dist"
],
"sideEffects": false,
"scripts": {
"build": "tsm ./scripts/build-export.ts",
"clean": "del ./dist/",
"test": "yarn clean && yarn build",
"test": "yarn clean && yarn build && yarn test:ssr",
"test:ssr": "node --test scripts/ssr.test.mjs scripts/ssr.test.cjs",
"prepublishOnly": "yarn test",
"start:sandbox": "yarn build && vite serve sandbox"
},
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const outputTypeDeclarations = async (icons: Record<string, string>) => {
const outputCJSBundle = async () => {
await buildSync({
entryPoints: [path.resolve(DIRECTORY_OUTPUT, 'index.js')],
outfile: path.resolve(DIRECTORY_OUTPUT, 'index.cjs.js'),
outfile: path.resolve(DIRECTORY_OUTPUT, 'index.cjs'),
format: 'cjs',
bundle: true,
external: ['react'],
Expand All @@ -90,7 +90,7 @@ const createESExportString = async (icons: Record<string, string>) => {
// const filePaths = await glob.sync(`${source}/*.svg`)
// apply export template to each and combine into single string
return Object.entries(icons)
.map(([name]) => `export * from './${name}'\n`)
.map(([name]) => `export * from './${name}.js'\n`)
.join('')
}

Expand Down
14 changes: 14 additions & 0 deletions scripts/ssr.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { test } = require('node:test')
const assert = require('node:assert/strict')
const icons = require('@atom-learning/icons')

test('CJS: package resolves via exports map in a Node SSR context', () => {
assert.ok(Object.keys(icons).length > 0, 'expected named exports')
})

test('CJS: known icons are exported as React components', () => {
for (const name of ['Accessibility', 'Activity', 'Add']) {
assert.equal(typeof icons[name], 'object', `${name} should be a forwardRef component`)
assert.equal(icons[name].displayName, name)
}
})
14 changes: 14 additions & 0 deletions scripts/ssr.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import * as icons from '@atom-learning/icons'

test('ESM: package resolves via exports map in a Node SSR context', () => {
assert.ok(Object.keys(icons).length > 0, 'expected named exports')
})

test('ESM: known icons are exported as React components', () => {
for (const name of ['Accessibility', 'Activity', 'Add']) {
assert.equal(typeof icons[name], 'object', `${name} should be a forwardRef component`)
assert.equal(icons[name].displayName, name)
}
})
Loading