Skip to content

Commit

Permalink
feat: migrating list editor to esm-only []
Browse files Browse the repository at this point in the history
  • Loading branch information
aodhagan-cf committed Oct 27, 2023
1 parent 5b4289e commit 103c147
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 27 deletions.
File renamed without changes.
10 changes: 4 additions & 6 deletions packages/list/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/* eslint-disable */
import baseConfig from '../../baseESMJestConfig.js';
import packageJSON from './package.json' assert { type: 'json' };

const baseConfig = require('../../baseJestConfig');
const packageName = packageJSON.name.split('@contentful/')[1];

const package = require('./package.json');
const packageName = package.name.split('@contentful/')[1];

module.exports = {
export default {
...baseConfig(packageName),
};
19 changes: 5 additions & 14 deletions packages/list/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
{
"name": "@contentful/field-editor-list",
"version": "1.4.2",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"type": "module",
"main": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"default": "./dist/cjs/index.js"
},
"./package.json": "./package.json"
},
"files": [
"dist"
],
Expand All @@ -23,12 +15,10 @@
},
"scripts": {
"watch": "yarn concurrently \"yarn:watch:*\"",
"watch:cjs": "yarn build:cjs -w",
"watch:esm": "yarn build:esm -w",
"watch:types": "yarn build:types --watch",
"build": "yarn build:types && yarn build:cjs && yarn build:esm",
"build": "yarn build:types && yarn build:esm",
"build:types": "tsc --outDir dist/types --emitDeclarationOnly",
"build:cjs": "swc src --config-file ../../.swcrc -d dist/cjs -C module.type=commonjs",
"build:esm": "swc src --config-file ../../.swcrc -d dist/esm",
"test": "jest --watch",
"test:ci": "jest --ci",
Expand All @@ -42,7 +32,8 @@
"lodash": "^4.17.15"
},
"devDependencies": {
"@contentful/field-editor-test-utils": "^1.4.3"
"@contentful/field-editor-test-utils": "^1.4.3",
"@jest/globals": "29.7.0"
},
"peerDependencies": {
"react": ">=16.8.0"
Expand Down
3 changes: 2 additions & 1 deletion packages/list/src/ListEditor.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as React from 'react';

import { createFakeFieldAPI, createFakeLocalesAPI } from '@contentful/field-editor-test-utils';
import { jest } from '@jest/globals';
import '@testing-library/jest-dom/extend-expect';
import { RenderResult, cleanup, configure, fireEvent, render } from '@testing-library/react';

import { ListEditor } from './ListEditor';
import { ListEditor } from './ListEditor.js';

configure({
testIdAttribute: 'data-test-id',
Expand Down
6 changes: 3 additions & 3 deletions packages/list/src/ListEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from 'react';

import { TextInput } from '@contentful/f36-components';
import { TextInput } from '@contentful/f36-forms';
import { FieldAPI, FieldConnector, LocalesAPI } from '@contentful/field-editor-shared';
import { FieldConnectorChildProps } from '@contentful/field-editor-shared';
import isEqual from 'lodash/isEqual';
import isEqual from 'lodash-es/isEqual.js';

import * as styles from './styles';
import * as styles from './styles.js';

export interface ListEditorProps {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/list/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { ListEditor } from './ListEditor';
export { ListEditor } from './ListEditor.js';
4 changes: 2 additions & 2 deletions packages/list/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"extends": "../../tsconfig.json",
"include": ["src", "types"],
"compilerOptions": {
"module": "esnext",
"moduleResolution": "bundler",
"module": "Node16",
"moduleResolution": "Node16",
"lib": ["dom", "esnext"],
"rootDir": "./src",
"baseUrl": "./",
Expand Down

0 comments on commit 103c147

Please sign in to comment.