Skip to content
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

Support the new jsx transform #1998

Merged
merged 4 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-games-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'modular-scripts': patch
---

Bump esbuild from 0.14.42 to 0.14.51
5 changes: 5 additions & 0 deletions .changeset/young-poets-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'modular-scripts': patch
---

Read `compilerOptions.jsx` when type checking to support the new React JSX transform.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@types/update-notifier": "5.1.0",
"@yarnpkg/lockfile": "^1.1.0",
"commander": "9.3.0",
"esbuild": "0.14.42",
"esbuild": "0.14.51",
"eslint": "7.32.0",
"execa": "5.1.1",
"husky": "8.0.1",
Expand All @@ -94,7 +94,7 @@
"typescript": "4.7.4"
},
"resolutions": {
"esbuild": "0.14.42"
"esbuild": "0.14.51"
},
"jest": {
"coveragePathIgnorePatterns": [
Expand Down
2 changes: 1 addition & 1 deletion packages/modular-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"detect-port-alt": "1.1.6",
"dotenv": "16.0.1",
"dotenv-expand": "8.0.3",
"esbuild": "0.14.42",
"esbuild": "0.14.51",
"esbuild-loader": "2.19.0",
"escape-string-regexp": "2.0.0",
"eslint": "7.32.0",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`when working with a NODE_ENV app WHEN building with esbuild can generate a js/index-FG4XHKNZ.js 1`] = `
exports[`when working with a NODE_ENV app WHEN building with esbuild can generate a js/index-AOVVUWA4.js 1`] = `
"console.log(\\"production\\");
//# sourceMappingURL=/static/js/index-FG4XHKNZ.js.map
//# sourceMappingURL=/static/js/index-AOVVUWA4.js.map
"
`;

Expand Down
16 changes: 8 additions & 8 deletions packages/modular-scripts/src/__tests__/app.esbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ describe('when working with an app', () => {
.toMatchInlineSnapshot(`
"sample-esbuild-app
├─ favicon.ico #6pu3rg
├─ index.html #nrfr3t
├─ index.html #zk3xji
├─ logo192.png #1nez7vk
├─ logo512.png #1hwqvcc
├─ manifest.json #19gah8o
├─ package.json
├─ robots.txt #1sjb8b3
└─ static
├─ css
│ ├─ index-OPRZV2UT.css #1ldttcq
│ └─ index-OPRZV2UT.css.map #za6yi0
│ ├─ index-PE2NG66F.css #1t4q6xl
│ └─ index-PE2NG66F.css.map #za6yi0
├─ js
│ ├─ index-LSDSCJMN.js #1cuiasc
│ └─ index-LSDSCJMN.js.map #5p9anu
│ ├─ index-TKIUYRMA.js #l9v7el
│ └─ index-TKIUYRMA.js.map #51gooi
└─ media
└─ logo-PGX3QVVN.svg #1okqmlj"
`);
Expand Down Expand Up @@ -123,7 +123,7 @@ describe('when working with an app', () => {
'sample-esbuild-app',
'static',
'js',
'index-LSDSCJMN.js',
'index-TKIUYRMA.js',
),
),
),
Expand All @@ -149,12 +149,12 @@ describe('when working with an app', () => {
};

it('can generate a index.js.map', () => {
expect(readSourceMap('static/js/index-LSDSCJMN.js.map')).toMatchSnapshot();
expect(readSourceMap('static/js/index-TKIUYRMA.js.map')).toMatchSnapshot();
});

it('can generate a index.css.map', () => {
expect(
readSourceMap('static/css/index-OPRZV2UT.css.map'),
readSourceMap('static/css/index-PE2NG66F.css.map'),
).toMatchSnapshot();
});
});
12 changes: 6 additions & 6 deletions packages/modular-scripts/src/__tests__/app.node-env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,20 @@ describe('when working with a NODE_ENV app', () => {
.toMatchInlineSnapshot(`
"node-env-app
├─ favicon.ico #6pu3rg
├─ index.html #yth8pd
├─ index.html #1g8070q
├─ logo192.png #1nez7vk
├─ logo512.png #1hwqvcc
├─ manifest.json #19gah8o
├─ package.json
├─ robots.txt #1sjb8b3
└─ static
└─ js
├─ index-FG4XHKNZ.js #449tgl
└─ index-FG4XHKNZ.js.map #j51j3v"
├─ index-AOVVUWA4.js #6j61pf
└─ index-AOVVUWA4.js.map #j51j3v"
`);
});

it('can generate a js/index-FG4XHKNZ.js', async () => {
it('can generate a js/index-AOVVUWA4.js', async () => {
expect(
prettier.format(
String(
Expand All @@ -140,12 +140,12 @@ describe('when working with a NODE_ENV app', () => {
'node-env-app',
'static',
'js',
'index-FG4XHKNZ.js',
'index-AOVVUWA4.js',
),
),
),
{
filepath: 'index-FG4XHKNZ.js',
filepath: 'index-AOVVUWA4.js',
},
),
).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe('WHEN running esbuild with the svgrPlugin', () => {
expect(err).toMatchInlineSnapshot(`
Object {
"detail": undefined,
"id": "",
"location": Object {
"column": 20,
"file": "packages/modular-scripts/src/__tests__/esbuild-scripts/__fixtures__/module-scope/src/index.tsx",
Expand Down
7 changes: 6 additions & 1 deletion packages/modular-scripts/src/typecheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function typecheck(): Promise<void> {

const { _compilerOptions, ...rest } = typescriptConfig;

const tsConfig = {
const tsConfig: typeof typescriptConfig = {
...rest,
exclude: [
'node_modules',
Expand All @@ -28,6 +28,11 @@ async function typecheck(): Promise<void> {
},
};

// If compilerOptions.jsx is defined use it otherwise, depend on the extended config by not setting it to undefined.
if (tsConfig.compilerOptions && rest.compilerOptions?.jsx) {
tsConfig.compilerOptions.jsx = rest.compilerOptions.jsx;
}

const diagnosticHost = {
getCurrentDirectory: (): string => getModularRoot(),
getNewLine: (): string => ts.sys.newLine,
Expand Down
Loading