Skip to content

Commit

Permalink
fix: jsx pragma with automatic runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Oct 21, 2020
1 parent 3d4ad74 commit c18f201
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/features/css-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ export default {
addNamed(path, 'F', 'astroturf', { nameHint: jsxFrag.name });

state.file.get(STYLES).changeset.unshift(
{ code: `/*${jsxPrgama}*/\n` },
{ code: `/*${jsxFragPrgama}*/\n\n` },
{ code: `/* @jsxRuntime classic */\n` },
{ code: `/${jsxPrgama}/\n` },
{ code: `/${jsxFragPrgama}/\n\n` },
{
code: `const { jsx: ${jsx.name}, F: ${jsxFrag.name} } = require('astroturf');\n`,
},
Expand Down
6 changes: 4 additions & 2 deletions test/__file_snapshots__/integration-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,11 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var widget__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! widget */ "./test/integration/shared/widget/index.js");
/* harmony import */ var _Button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Button */ "./test/integration/Button.js");
/** @jsx _j **/
/* @jsxRuntime classic */

/** @jsxFrag _f **/
/* @jsx _j */

/* @jsxFrag _f */
const {
jsx: _j,
F: _f
Expand Down
5 changes: 3 additions & 2 deletions test/__file_snapshots__/loader__css-prop.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @jsx _j **/
/** @jsxFrag _f **/
/* @jsxRuntime classic */
/* @jsx _j */
/* @jsxFrag _f */

const { jsx: _j, F: _f } = require("astroturf");

Expand Down
5 changes: 3 additions & 2 deletions test/__file_snapshots__/loader__typescript.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @jsx _j **/
/** @jsxFrag _f **/
/* @jsxRuntime classic */
/* @jsx _j */
/* @jsxFrag _f */

const { jsx: _j, F: _f } = require("astroturf");
import styled from "astroturf";
Expand Down
5 changes: 2 additions & 3 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ describe('webpack loader', () => {
`,
{ enableCssProp: true },
);

expect(code.includes('/** @jsx _j **/')).toBe(true);
expect(code.includes('/** @jsxFrag _f **/')).toBe(true);
expect(code.includes('/* @jsx _j */')).toBe(true);
expect(code.includes('/* @jsxFrag _f */')).toBe(true);

expect(
code.includes('[require("./MyStyleFile-CssProp1_button.css")'),
Expand Down

0 comments on commit c18f201

Please sign in to comment.