Skip to content

Commit

Permalink
build: migrate to ESM
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This package is now packaged using ESM.

Stryker has been removed due to its poor support for ESM environments.
  • Loading branch information
keplersj committed Sep 28, 2021
1 parent 5108636 commit c9a4b19
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Expand Up @@ -15,8 +15,8 @@ jobs:
run: npm ci
- name: Run tests
run: npm test -- --ci
- name: Run Stryker
run: npx stryker run
# - name: Run Stryker
# run: npx stryker run
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2.1.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .storybook/main.js
Expand Up @@ -2,7 +2,7 @@ module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-docs",
"@storybook/addon-essentials",
],
};
3 changes: 3 additions & 0 deletions .storybook/package.json
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -14,6 +14,8 @@ The most notable "theming" feature of these components is their automatic dark m
npm install starstuff-components
```

This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c);

## Usage

All components can be access via named exports on the `starstuff-components` package. Detailed examples for each component can be seen below.
Expand Down
10 changes: 9 additions & 1 deletion jest.config.js → jest.config.cjs
Expand Up @@ -11,10 +11,18 @@ module.exports = {
projects: [
{
displayName: "test",
preset: "ts-jest",
preset: "ts-jest/presets/default-esm",
snapshotSerializers: ["@emotion/jest/serializer"],
testPathIgnorePatterns,
collectCoverage: true,
globals: {
"ts-jest": {
useESM: true,
},
},
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
},
{
displayName: "lint:prettier",
Expand Down
7 changes: 6 additions & 1 deletion package.json
Expand Up @@ -2,7 +2,12 @@
"name": "starstuff-components",
"version": "0.0.0-development",
"description": "Minimalistic React Component Library",
"main": "dist/index.js",
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"scripts": {
"build": "tsc",
"prepack": "tsc",
Expand Down
2 changes: 1 addition & 1 deletion src/Card/index.test.tsx
Expand Up @@ -3,7 +3,7 @@
*/

import * as React from "react";
import renderer from "react-test-renderer";
import * as renderer from "react-test-renderer";
import { Card } from ".";

describe("Card", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Hyperbutton/index.test.tsx
Expand Up @@ -3,7 +3,7 @@
*/

import * as React from "react";
import renderer from "react-test-renderer";
import * as renderer from "react-test-renderer";
import { Hyperbutton } from ".";

describe("Hyperbutton", (): void => {
Expand Down
2 changes: 1 addition & 1 deletion src/Hyperlink/index.test.tsx
Expand Up @@ -3,7 +3,7 @@
*/

import * as React from "react";
import renderer from "react-test-renderer";
import * as renderer from "react-test-renderer";
import { Hyperlink } from ".";

describe("Hyperlink", (): void => {
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
@@ -1,3 +1,3 @@
export { Card } from "./Card";
export { Hyperbutton } from "./Hyperbutton";
export { Hyperlink } from "./Hyperlink";
export { Card } from "./Card/index.js";
export { Hyperbutton } from "./Hyperbutton/index.js";
export { Hyperlink } from "./Hyperlink/index.js";
23 changes: 0 additions & 23 deletions stryker.conf.js

This file was deleted.

8 changes: 4 additions & 4 deletions tsconfig.json
Expand Up @@ -2,8 +2,8 @@
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ES2018" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "ES2020" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
Expand Down Expand Up @@ -39,14 +39,14 @@
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

Expand Down

0 comments on commit c9a4b19

Please sign in to comment.