-
Notifications
You must be signed in to change notification settings - Fork 116
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
feat: testing branch for ESM-only packages [] #1526
base: feat/esm-only
Are you sure you want to change the base?
Changes from 1 commit
ad55bf2
1e6cdb6
2f12c99
fd7ac2c
0f4aad5
4567469
36bf283
e9dfe95
5b4289e
103c147
36a57f0
f190274
162268f
3472fa9
df4b3ff
cb270e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,8 @@ | |
} | ||
}, | ||
"module": { | ||
"type": "es6" | ||
"type": "es6", | ||
"strict": false | ||
}, | ||
"minify": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* eslint-disable */ | ||
|
||
function getConfig(packageName) { | ||
return { | ||
testEnvironment: 'jsdom', | ||
modulePathIgnorePatterns: ['<rootDir>/dist/'], | ||
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'], | ||
extensionsToTreatAsEsm: ['.ts', '.tsx'], | ||
moduleNameMapper: { | ||
'^(\\.\\.?\\/.+)\\.js$': '$1', | ||
}, | ||
transform: { | ||
'^.+\\.tsx?$': ['@swc/jest'], | ||
}, | ||
reporters: [ | ||
'default', | ||
[ | ||
'jest-junit', | ||
{ | ||
outputDirectory: '../../reports', | ||
outputName: `${packageName}-results.xml`, | ||
addFileAttribute: true, | ||
}, | ||
], | ||
], | ||
}; | ||
} | ||
|
||
module.exports = getConfig; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
/* eslint-disable */ | ||
const baseConfig = require('../../baseESMJestConfig.js'); | ||
|
||
const baseConfig = require('../../baseJestConfig'); | ||
const packageJSON = require('./package.json'); | ||
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), | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
{ | ||
"name": "@contentful/field-editor-json", | ||
"version": "3.3.6", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"type": "module", | ||
"main": "dist/esm/index.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This package stores the files in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense will do! |
||
"types": "dist/types/index.d.ts", | ||
"exports": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need them or not? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andipaetzold going to tag you on this comment if that's okay? I don't think we need it, I've tested this in the web app and it works, but have also seen some articles recommending to have it in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we don't need it |
||
".": { | ||
"types": "./dist/types/index.d.ts", | ||
"require": "./dist/cjs/index.js", | ||
"default": "./dist/esm/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
|
@@ -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", | ||
"tsc": "tsc -p ./ --noEmit" | ||
}, | ||
|
@@ -38,13 +28,14 @@ | |
"@contentful/f36-tokens": "^4.0.0", | ||
"@contentful/field-editor-shared": "^1.4.2", | ||
"@types/deep-equal": "1.0.1", | ||
"@types/react-codemirror": "1.0.3", | ||
"@uiw/react-codemirror": "^4.11.4", | ||
"@types/react-codemirror": "1.0.10", | ||
"@uiw/react-codemirror": "^4.21.20", | ||
"deep-equal": "2.2.2", | ||
"emotion": "^10.0.17", | ||
"lodash": "^4.17.15" | ||
}, | ||
"devDependencies": { | ||
"@types/lodash-es": "4.17.9", | ||
"@contentful/field-editor-test-utils": "^1.4.3" | ||
}, | ||
"peerDependencies": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,10 @@ import { json } from '@codemirror/lang-json'; | |
import { indentUnit } from '@codemirror/language'; | ||
import { EditorView } from '@codemirror/view'; | ||
import tokens from '@contentful/f36-tokens'; | ||
import CodeMirror from '@uiw/react-codemirror'; | ||
import CodeMirror from '@uiw/react-codemirror/esm/index.js'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ why do we need to import from |
||
import { css, cx } from 'emotion'; | ||
|
||
import { SPACE_INDENT_COUNT } from './utils'; | ||
import { SPACE_INDENT_COUNT } from './utils.js'; | ||
|
||
type JsonEditorFieldProps = { | ||
isDisabled: boolean; | ||
|
@@ -60,6 +60,7 @@ export function JsonEditorField(props: JsonEditorFieldProps) { | |
className={cx(styles.root, { disabled: props.isDisabled })} | ||
data-test-id="json-editor-code-mirror" | ||
> | ||
{/* @ts-expect-error */} | ||
<CodeMirror | ||
value={props.value} | ||
onChange={props.onChange} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import JsonEditor from './JsonEditor'; | ||
import JsonEditor from './JsonEditor.js'; | ||
|
||
export { JsonEditor }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: depending on your preference