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

Migrate packages to ESM #2061

Merged
merged 24 commits into from
Apr 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d6f9b9d
Replace ts-node with tsx
connor-baer Apr 23, 2023
05a83a3
Migrate @sumup/icons to ESM
connor-baer Apr 23, 2023
6b53ea6
Switch @sumup/icons to package exports
connor-baer Apr 23, 2023
78bbb45
Migrate @sumup/design-tokens to ESM
connor-baer Apr 23, 2023
3df3537
Configure @sumup/circuit-ui as a module
connor-baer Apr 24, 2023
f7d75d3
Add file extensions using eslint-plugin-node
connor-baer Apr 24, 2023
5ed2a80
Add extensions to component index files
connor-baer Apr 24, 2023
13abb54
Search and insert file extensions
connor-baer Apr 24, 2023
11f9f11
Proxy isPropValid import
connor-baer Apr 24, 2023
c211966
Fix Storybook imports
connor-baer Apr 24, 2023
c875bb9
Fix css prop types
connor-baer Apr 25, 2023
d702303
Internalize usePrevious and useLatest hooks
connor-baer Apr 25, 2023
e63bac0
Fix import resolution and dependency cycles
connor-baer Apr 25, 2023
3fea6d3
Use .js for all file extensions
connor-baer Apr 25, 2023
c21552d
Switch Storybook to Vite
connor-baer Apr 25, 2023
c32d93b
Upgrade @storybook/* packages to latest
connor-baer Apr 25, 2023
1274f6a
Add extensions in story and spec files
connor-baer Apr 26, 2023
2d0e54d
Remove Babel
connor-baer Apr 26, 2023
74db9e2
Integrate Vite with Turbosnap
connor-baer Apr 26, 2023
71bc2f1
Re-add exports after rebase
connor-baer Apr 26, 2023
895e68f
Add code comments for Emotion workaround
connor-baer Apr 26, 2023
8205c2c
Add changesets
connor-baer Apr 27, 2023
f1f5a71
Raise the minimum Node.js version to 16+
connor-baer Apr 27, 2023
df9d81f
Add unit tests for useLatest and usePrevious
connor-baer Apr 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .changeset/flat-lamps-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sumup/design-tokens': major
'@sumup/circuit-ui': major
'@sumup/icons': major
---

Raised the minimum Node.js version to 16+. This is the first maintained version with support for ES modules.
connor-baer marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions .changeset/grumpy-donuts-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@sumup/design-tokens': major
'@sumup/circuit-ui': major
'@sumup/icons': major
---

**This package is now pure ESM**. Please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).

- If you use TypeScript, you need to use TypeScript 4.7 or later ([ref](https://github.com/microsoft/TypeScript/issues/46452)).
- If you use a bundler, make sure it supports ESM and that you have correctly configured it for ESM. (Next.js supports ESM packages out of the box since [v12](https://nextjs.org/blog/next-12#es-modules-support-and-url-imports)).
7 changes: 7 additions & 0 deletions .changeset/red-experts-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sumup/design-tokens': major
'@sumup/circuit-ui': major
'@sumup/icons': major
---

Switched to the `"exports"` field to configure the package entry points. Files that are not explicitly defined in `"exports"` can no longer be imported.
11 changes: 11 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
module.exports = require('@sumup/foundry/eslint')({
plugins: ['@sumup/circuit-ui'],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: ['./packages/*/tsconfig.json', './tsconfig.eslint.json'],
},
},
},
rules: {
'@sumup/circuit-ui/no-invalid-custom-properties': 'error',
'react/no-unknown-property': ['error', { ignore: ['css'] }],
Expand Down
30 changes: 12 additions & 18 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { StorybookConfig } from '@storybook/react-webpack5';
import type { PluginItem } from '@babel/core';
import type { StorybookConfig } from '@storybook/react-vite';
import path from 'path';
import remarkGfm from 'remark-gfm';
import { mergeConfig } from 'vite';
import turbosnap from 'vite-plugin-turbosnap';

const toPath = (_path: string) => path.join(process.cwd(), _path);

Expand Down Expand Up @@ -35,24 +36,17 @@ const config: StorybookConfig = {
disableTelemetry: true,
},
framework: {
name: '@storybook/react-webpack5',
name: '@storybook/react-vite',
options: {},
},
babel: async (options) => ({
...options,
presets: [
...(options.presets as PluginItem[]),
// HACK: Storybook includes `@babel/preset-react` by default, which
// overrides the custom preset configuration in `babel.config.json`.
// This override overrides the override.
[
'@babel/preset-react',
{ runtime: 'automatic', importSource: '@emotion/react' },
'preset-jsx-import-source',
],
'@babel/preset-typescript',
],
}),
async viteFinal(config, { configType }) {
return mergeConfig(config, {
plugins:
configType === 'PRODUCTION'
? [turbosnap({ rootDir: config.root ?? process.cwd() })]
: [],
});
},
};

export default config;
26 changes: 0 additions & 26 deletions babel.config.json

This file was deleted.

Loading