Skip to content

Commit

Permalink
update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio committed Sep 25, 2023
1 parent 5fe5d7e commit d5e6c59
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 179 deletions.
196 changes: 55 additions & 141 deletions packages/babel-preset-default/__tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,26 @@ Object.defineProperty(exports, \\"__esModule\\", {
});
exports.default = void 0;
var _react = require(\\"react\\");
var _jsxRuntime = require(\\"react/jsx-runtime\\");
// eslint-disable-line import/no-extraneous-dependencies
// eslint-disable-line import/no-extraneous-dependencies
const FCComponent = ({
title,
url,
description
}) => /*#__PURE__*/React.createElement(\\"div\\", {
className: \\"component-test-babel\\"
}, /*#__PURE__*/React.createElement(\\"a\\", {
href: url,
title: title
}, /*#__PURE__*/React.createElement(\\"h1\\", null, title)), /*#__PURE__*/React.createElement(\\"p\\", null, description));
}) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(\\"div\\", {
className: \\"component-test-babel\\",
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(\\"a\\", {
href: url,
title: title,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(\\"h1\\", {
children: title
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(\\"p\\", {
children: description
})]
});
FCComponent.defaultProps = {
title: '',
url: '',
Expand All @@ -104,13 +111,15 @@ class ClassComponent extends _react.Component {
const {
title
} = this.props;
return /*#__PURE__*/React.createElement(\\"div\\", {
className: \\"Class Component\\"
}, /*#__PURE__*/React.createElement(\\"h1\\", null, title));
return /*#__PURE__*/(0, _jsxRuntime.jsx)(\\"div\\", {
className: \\"Class Component\\",
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(\\"h1\\", {
children: title
})
});
}
}
var _default = FCComponent;
exports.default = _default;"
var _default = exports.default = FCComponent;"
`;
exports[`Babel preset default transpiles without removing proptypes in dev mode 1`] = `
Expand All @@ -122,46 +131,42 @@ Object.defineProperty(exports, \\"__esModule\\", {
exports.default = void 0;
var _react = require(\\"react\\");
var _propTypes = _interopRequireDefault(require(\\"prop-types\\"));
var _jsxDevRuntime = require(\\"react/jsx-dev-runtime\\");
var _jsxFileName = \\"\\"; // eslint-disable-line import/no-extraneous-dependencies
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// eslint-disable-line import/no-extraneous-dependencies
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const FCComponent = ({
title,
url,
description
}) => /*#__PURE__*/React.createElement(\\"div\\", {
}) => /*#__PURE__*/(0, _jsxDevRuntime.jsxDEV)(\\"div\\", {
className: \\"component-test-babel\\",
__self: void 0,
__source: {
fileName: _jsxFileName,
lineNumber: 5,
columnNumber: 2
}
}, /*#__PURE__*/React.createElement(\\"a\\", {
href: url,
title: title,
__self: void 0,
__source: {
children: [/*#__PURE__*/(0, _jsxDevRuntime.jsxDEV)(\\"a\\", {
href: url,
title: title,
children: /*#__PURE__*/(0, _jsxDevRuntime.jsxDEV)(\\"h1\\", {
children: title
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 7,
columnNumber: 4
}, void 0)
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 6,
columnNumber: 3
}
}, /*#__PURE__*/React.createElement(\\"h1\\", {
__self: void 0,
__source: {
fileName: _jsxFileName,
lineNumber: 7,
columnNumber: 4
}
}, title)), /*#__PURE__*/React.createElement(\\"p\\", {
__self: void 0,
__source: {
}, void 0), /*#__PURE__*/(0, _jsxDevRuntime.jsxDEV)(\\"p\\", {
children: description
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 9,
columnNumber: 3
}
}, description));
}, void 0)]
}, void 0, true, {
fileName: _jsxFileName,
lineNumber: 5,
columnNumber: 2
}, void 0);
FCComponent.propTypes = {
title: _propTypes.default.string,
url: _propTypes.default.string,
Expand All @@ -180,29 +185,26 @@ class ClassComponent extends _react.Component {
const {
title
} = this.props;
return /*#__PURE__*/React.createElement(\\"div\\", {
return /*#__PURE__*/(0, _jsxDevRuntime.jsxDEV)(\\"div\\", {
className: \\"Class Component\\",
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 33,
columnNumber: 4
}
}, /*#__PURE__*/React.createElement(\\"h1\\", {
__self: this,
__source: {
children: /*#__PURE__*/(0, _jsxDevRuntime.jsxDEV)(\\"h1\\", {
children: title
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 34,
columnNumber: 5
}
}, title));
}, this)
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 33,
columnNumber: 4
}, this);
}
}
ClassComponent.propTypes = {
title: _propTypes.default.string.isRequired
};
var _default = FCComponent;
exports.default = _default;"
var _default = exports.default = FCComponent;"
`;
exports[`Babel preset default transpiles without transforming es6 imports 1`] = `
Expand Down Expand Up @@ -278,95 +280,7 @@ class ClassComponent extends _react.Component {
}, (0, _element.createElement)(\\"h1\\", null, title));
}
}
var _default = FCComponent;
exports.default = _default;"
`;
exports[`Babel preset default with automatic runtime transpiles react code properly with automatic runtime 1`] = `
"\\"use strict\\";
Object.defineProperty(exports, \\"__esModule\\", {
value: true
});
exports.default = void 0;
var _react = require(\\"react\\");
// eslint-disable-line import/no-extraneous-dependencies
// eslint-disable-line import/no-extraneous-dependencies
const FCComponent = ({
title,
url,
description
}) => /*#__PURE__*/React.createElement(\\"div\\", {
className: \\"component-test-babel\\"
}, /*#__PURE__*/React.createElement(\\"a\\", {
href: url,
title: title
}, /*#__PURE__*/React.createElement(\\"h1\\", null, title)), /*#__PURE__*/React.createElement(\\"p\\", null, description));
FCComponent.defaultProps = {
title: '',
url: '',
description: ''
};
class ClassComponent extends _react.Component {
componentDidMount() {
// doing something
}
render() {
const {
title
} = this.props;
return /*#__PURE__*/React.createElement(\\"div\\", {
className: \\"Class Component\\"
}, /*#__PURE__*/React.createElement(\\"h1\\", null, title));
}
}
var _default = FCComponent;
exports.default = _default;"
`;
exports[`Babel preset default with automatic runtime transpiles wordpress code properly even when jsx-runtime.js is present 1`] = `
"\\"use strict\\";
Object.defineProperty(exports, \\"__esModule\\", {
value: true
});
exports.default = void 0;
var _element = require(\\"@wordpress/element\\");
var _react = require(\\"react\\");
// eslint-disable-line import/no-extraneous-dependencies
// eslint-disable-line import/no-extraneous-dependencies
const FCComponent = ({
title,
url,
description
}) => (0, _element.createElement)(\\"div\\", {
className: \\"component-test-babel\\"
}, (0, _element.createElement)(\\"a\\", {
href: url,
title: title
}, (0, _element.createElement)(\\"h1\\", null, title)), (0, _element.createElement)(\\"p\\", null, description));
FCComponent.defaultProps = {
title: '',
url: '',
description: ''
};
class ClassComponent extends _react.Component {
componentDidMount() {
// doing something
}
render() {
const {
title
} = this.props;
return (0, _element.createElement)(\\"div\\", {
className: \\"Class Component\\"
}, (0, _element.createElement)(\\"h1\\", null, title));
}
}
var _default = FCComponent;
exports.default = _default;"
var _default = exports.default = FCComponent;"
`;
exports[`compiles typescript transpiles typescript code properly 1`] = `
Expand Down
30 changes: 0 additions & 30 deletions packages/babel-preset-default/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,36 +90,6 @@ describe('Babel preset default', () => {
});
});

describe('Babel preset default with automatic runtime', () => {
beforeEach(() => {
// fs.writeFileSync(path.join(reactPath, 'jsx-runtime.js'), 'export default () => {};');
});

afterEach(() => {
// fs.unlinkSync(path.join(reactPath, 'jsx-runtime.js'));
});

test('transpiles react code properly with automatic runtime', () => {
const output = babel.transform(reactInput, {
configFile: false,
envName: 'production',
presets: [babelPresetDefault],
});

expect(output.code).toMatchSnapshot();
});

test('transpiles wordpress code properly even when jsx-runtime.js is present', () => {
const output = babel.transform(reactInput, {
configFile: false,
envName: 'production',
presets: [[babelPresetDefault, { wordpress: true }]],
});

expect(output.code).toMatchSnapshot();
});
});

describe('compiles typescript', () => {
test('transpiles typescript code properly', () => {
const output = babel.transform(tsInput, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ Object {
CopyPlugin: {},
StylelintWebpackPlugin: {"cache":true,"cacheLocation":"node_modules/.cache/stylelint-webpack-plugin/.stylelintcache","extensions":["css","scss","sass"],"emitError":true,"emitWarning":true,"failOnError":false,"context":"/assets2","files":"**/*.(s(c|a)ss|css)","allowEmptyInput":true,"lintDirtyModulesOnly":true},
WebpackBarPlugin: {"name":"webpack","color":"green","reporters":["basic"],"reporter":null},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"__experimentalInjectInteractivityRuntime":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
CleanExtractedDeps: {},
WebpackRemoveEmptyScriptsPlugin: {"enabled":true,"verbose":false,"extensions":{},"ignore":[],"remove":{}},
TenUpToolkitTscPlugin: {},
Expand Down Expand Up @@ -1599,7 +1599,7 @@ Object {
NoBrowserSyncPlugin: {},
StylelintWebpackPlugin: {"cache":true,"cacheLocation":"node_modules/.cache/stylelint-webpack-plugin/.stylelintcache","extensions":["css","scss","sass"],"emitError":true,"emitWarning":true,"failOnError":false,"context":"/assets2","files":"**/*.(s(c|a)ss|css)","allowEmptyInput":true,"lintDirtyModulesOnly":true,"configFile":"/config/stylelint.config.js"},
WebpackBarPlugin: {"name":"webpack","color":"green","reporters":["basic"],"reporter":null},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"__experimentalInjectInteractivityRuntime":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
CleanExtractedDeps: {},
WebpackRemoveEmptyScriptsPlugin: {"enabled":true,"verbose":false,"extensions":{},"ignore":[],"remove":{}},
TenUpToolkitTscPlugin: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ Object {
NoBrowserSyncPlugin: {},
StylelintWebpackPlugin: {"cache":true,"cacheLocation":"node_modules/.cache/stylelint-webpack-plugin/.stylelintcache","extensions":["css","scss","sass"],"emitError":true,"emitWarning":true,"failOnError":false,"context":"/assets","files":"**/*.(s(c|a)ss|css)","allowEmptyInput":true,"lintDirtyModulesOnly":true},
WebpackBarPlugin: {"name":"webpack","color":"green","reporters":["basic"],"reporter":null},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"__experimentalInjectInteractivityRuntime":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
CleanExtractedDeps: {},
WebpackRemoveEmptyScriptsPlugin: {"enabled":true,"verbose":false,"extensions":{},"ignore":[],"remove":{}},
TenUpToolkitTscPlugin: {},
Expand Down Expand Up @@ -695,7 +695,7 @@ Object {
CopyPlugin: {},
StylelintWebpackPlugin: {"cache":true,"cacheLocation":"node_modules/.cache/stylelint-webpack-plugin/.stylelintcache","extensions":["css","scss","sass"],"emitError":true,"emitWarning":true,"failOnError":false,"context":"/assets","files":"**/*.(s(c|a)ss|css)","allowEmptyInput":true,"lintDirtyModulesOnly":true},
WebpackBarPlugin: {"name":"webpack","color":"green","reporters":["basic"],"reporter":null},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"__experimentalInjectInteractivityRuntime":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
CleanExtractedDeps: {},
WebpackRemoveEmptyScriptsPlugin: {"enabled":true,"verbose":false,"extensions":{},"ignore":[],"remove":{}},
TenUpToolkitTscPlugin: {},
Expand Down Expand Up @@ -905,7 +905,7 @@ Object {
CopyPlugin: {},
StylelintWebpackPlugin: {"cache":true,"cacheLocation":"node_modules/.cache/stylelint-webpack-plugin/.stylelintcache","extensions":["css","scss","sass"],"emitError":true,"emitWarning":true,"failOnError":false,"context":"/assets","files":"**/*.(s(c|a)ss|css)","allowEmptyInput":true,"lintDirtyModulesOnly":true},
WebpackBarPlugin: {"name":"webpack","color":"green","reporters":["basic"],"reporter":null},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"__experimentalInjectInteractivityRuntime":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
CleanExtractedDeps: {},
WebpackRemoveEmptyScriptsPlugin: {"enabled":true,"verbose":false,"extensions":{},"ignore":[],"remove":{}},
TenUpToolkitTscPlugin: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Object {
MiniCssExtractPlugin: {"ignoreOrder":false,"runtime":true,"chunkFilename":"[id].css"},
CopyPlugin: {},
StylelintWebpackPlugin: {"cache":true,"cacheLocation":"node_modules/.cache/stylelint-webpack-plugin/.stylelintcache","extensions":["css","scss","sass"],"emitError":true,"emitWarning":true,"failOnError":false,"context":"/assets","files":"**/*.(s(c|a)ss|css)","allowEmptyInput":true,"lintDirtyModulesOnly":true},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"__experimentalInjectInteractivityRuntime":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
CleanExtractedDeps: {},
WebpackRemoveEmptyScriptsPlugin: {"enabled":true,"verbose":false,"extensions":{},"ignore":[],"remove":{}},
TenUpToolkitTscPlugin: {},
Expand Down Expand Up @@ -245,7 +245,7 @@ Array [
"path": "/dist/fast-refresh",
},
"plugins": Array [
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"__experimentalInjectInteractivityRuntime":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"outputFormat":"php","outputFilename":null,"useDefaults":true},
],
},
Object {
Expand All @@ -265,7 +265,7 @@ Array [
"path": "/dist/fast-refresh",
},
"plugins": Array [
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"__experimentalInjectInteractivityRuntime":false,"outputFormat":"php","outputFilename":null,"useDefaults":false},
DependencyExtractionWebpackPlugin: {"combineAssets":false,"combinedOutputFile":null,"externalizedReport":false,"injectPolyfill":false,"outputFormat":"php","outputFilename":null,"useDefaults":false},
],
},
]
Expand Down

0 comments on commit d5e6c59

Please sign in to comment.