Skip to content

Commit

Permalink
[*] [babel] add babel-plugin-add-module-exports and fully use ESM s…
Browse files Browse the repository at this point in the history
…yntax
  • Loading branch information
ljharb committed Nov 3, 2022
1 parent 538b0d8 commit 18527e8
Show file tree
Hide file tree
Showing 47 changed files with 57 additions and 39 deletions.
5 changes: 3 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"presets": ["airbnb"],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
ignore: [
"ignore": [
"packages/enzyme-test-suite/test/_helpers/untranspiled*",
],
sourceMaps: "both",
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@babel/register": "^7.18.9",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"chai": "^4.3.4",
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-13/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-13/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"enzyme": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,4 @@ class ReactThirteenAdapter extends EnzymeAdapter {
}
}

module.exports = ReactThirteenAdapter;
export default ReactThirteenAdapter;
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-14/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-14/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"enzyme": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,4 @@ class ReactFourteenAdapter extends EnzymeAdapter {
}
}

module.exports = ReactFourteenAdapter;
export default ReactFourteenAdapter;
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-15.4/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-15.4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"enzyme": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,4 @@ class ReactFifteenFourAdapter extends EnzymeAdapter {
}
}

module.exports = ReactFifteenFourAdapter;
export default ReactFifteenFourAdapter;
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-15/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-15/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"enzyme": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,4 @@ class ReactFifteenAdapter extends EnzymeAdapter {
}
}

module.exports = ReactFifteenAdapter;
export default ReactFifteenAdapter;
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-16.1/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-16.1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"enzyme": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,4 +567,4 @@ class ReactSixteenOneAdapter extends EnzymeAdapter {
}
}

module.exports = ReactSixteenOneAdapter;
export default ReactSixteenOneAdapter;
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-16.2/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-16.2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"enzyme": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,4 +573,4 @@ class ReactSixteenTwoAdapter extends EnzymeAdapter {
}
}

module.exports = ReactSixteenTwoAdapter;
export default ReactSixteenTwoAdapter;
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-16.3/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-16.3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"enzyme": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,4 +640,4 @@ class ReactSixteenThreeAdapter extends EnzymeAdapter {
}
}

module.exports = ReactSixteenThreeAdapter;
export default ReactSixteenThreeAdapter;
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-16/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-16/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"enzyme": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -991,4 +991,4 @@ class ReactSixteenAdapter extends EnzymeAdapter {
}
}

module.exports = ReactSixteenAdapter;
export default ReactSixteenAdapter;
4 changes: 2 additions & 2 deletions packages/enzyme-adapter-react-16/src/detectFiberTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function getLazyFiber(LazyComponent) {
return inst._reactInternalFiber.child;
}

module.exports = function detectFiberTags() {
export default function detectFiberTags() {
const supportsMode = typeof React.StrictMode !== 'undefined';
const supportsContext = typeof React.createContext !== 'undefined';
const supportsForwardRef = typeof React.forwardRef !== 'undefined';
Expand Down Expand Up @@ -108,4 +108,4 @@ module.exports = function detectFiberTags() {
? getLazyFiber(LazyComponent).tag
: -1,
};
};
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-utils/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"eslint": "^8.24.0",
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-example-mocha/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
}
1 change: 1 addition & 0 deletions packages/enzyme-example-mocha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@babel/cli": "^7.15.4",
"@babel/core": "^7.15.5",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"eslint": "^7.32.0",
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-shallow-equal/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions packages/enzyme-shallow-equal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"eslint": "^8.24.0",
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-test-suite/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
3 changes: 2 additions & 1 deletion packages/enzyme-test-suite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"devDependencies": {
"@babel/cli": "^7.15.4",
"@babel/core": "^7.15.5",
"babel-eslint": "^10.1.0",
"@babel/eslint-parser": "^7.19.1",
"babel-plugin-add-module-exports": "^1.0.4",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.24.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/enzyme-test-suite/test/_helpers/describeHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function describeHooks({

hooks.forEach((hook) => {
// eslint-disable-next-line global-require, import/no-dynamic-require
require(`../shared/hooks/${hook}`).default({
require(`../shared/hooks/${hook}`)({
hasHooks: is('>= 16.8'),
Wrap,
WrapRendered: isShallow ? Wrap : (...args) => Wrap(...args).children(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function describeLifecycles({

lifecycles.forEach((lifecycle) => {
// eslint-disable-next-line global-require, import/no-dynamic-require
require(`../shared/lifecycles/${lifecycle}`).default({
require(`../shared/lifecycles/${lifecycle}`)({
Wrap,
WrapRendered: isShallow ? Wrap : (...args) => Wrap(...args).children(),
Wrapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function describeMethods({

methods.forEach((method) => {
// eslint-disable-next-line global-require, import/no-dynamic-require
require(`../shared/methods/${method}`).default({
require(`../shared/methods/${method}`)({
Wrap,
WrapRendered: isShallow ? Wrap : (...args) => Wrap(...args).children(),
Wrapper,
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
["add-module-exports"],
],
"sourceMaps": "both",
}
2 changes: 1 addition & 1 deletion packages/enzyme/ReactWrapper.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./build/ReactWrapper').default;
module.exports = require('./build/ReactWrapper');
2 changes: 1 addition & 1 deletion packages/enzyme/ShallowWrapper.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./build/ShallowWrapper').default;
module.exports = require('./build/ShallowWrapper');
2 changes: 1 addition & 1 deletion packages/enzyme/mount.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./build/mount').default;
module.exports = require('./build/mount');
1 change: 1 addition & 0 deletions packages/enzyme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"eslint": "^8.24.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/enzyme/render.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./build/render').default;
module.exports = require('./build/render');
2 changes: 1 addition & 1 deletion packages/enzyme/shallow.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./build/shallow').default;
module.exports = require('./build/shallow');
2 changes: 1 addition & 1 deletion packages/enzyme/src/EnzymeAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ EnzymeAdapter.MODES = {
SHALLOW: 'shallow',
};

module.exports = EnzymeAdapter;
export default EnzymeAdapter;
24 changes: 7 additions & 17 deletions packages/enzyme/src/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import ReactWrapper from './ReactWrapper';
import ShallowWrapper from './ShallowWrapper';
import EnzymeAdapter from './EnzymeAdapter';
export { default as ReactWrapper } from './ReactWrapper';
export { default as ShallowWrapper } from './ShallowWrapper';
export { default as EnzymeAdapter } from './EnzymeAdapter';

import mount from './mount';
import shallow from './shallow';
import render from './render';
import { merge as configure } from './configuration';

module.exports = {
render,
shallow,
mount,
ShallowWrapper,
ReactWrapper,
configure,
EnzymeAdapter,
};
export { default as mount } from './mount';
export { default as shallow } from './shallow';
export { default as render } from './render';
export { merge as configure } from './configuration';

0 comments on commit 18527e8

Please sign in to comment.