Skip to content

Commit

Permalink
Merge pull request #1577 from okta/kg/OKTA-535175
Browse files Browse the repository at this point in the history
fix: compatibility issues with TypeScript in custom Babel plugins
  • Loading branch information
KevinGhadyani-Okta authored Sep 28, 2022
2 parents 8f8f6b2 + fc5a214 commit 9740d6d
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 236 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"packages/*"
],
"resolutions": {
"@babel/plugin-transform-typescript": "^7.19.1"
"@babel/plugin-transform-typescript": "^7.19.1",
"@types/babel__traverse": "^7.18.1"
},
"engines": {
"yarn": "^3.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-fully-specified/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@babel/types": "^7.19.0"
},
"devDependencies": {
"@babel/core": "^7.19.1",
"@babel/core": "^7.19.3",
"@okta/odyssey-lifecycle": "^0.15.0",
"@okta/odyssey-typescript": "^0.15.0",
"jest": "^29.0.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/odyssey-babel-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"postcss-load-config": "^3.1.0"
},
"devDependencies": {
"@babel/core": "^7.19.1",
"@babel/core": "^7.19.3",
"@okta/odyssey-lifecycle": "^0.15.0",
"@okta/odyssey-postcss-preset": "^0.15.0",
"@okta/odyssey-typescript": "^0.15.0",
"jest": "^29.0.3",
"postcss": "^8.3.6",
"postcss": "^8.4.16",
"typescript": "^4.8.3"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/odyssey-babel-plugin/src/compileFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export default function compileFactory(): Compile {
delete result.message.warning;
}

worker.unref();

return result.message;
};

worker.unref();

return compile;
}
11 changes: 5 additions & 6 deletions packages/odyssey-babel-plugin/src/normalizeOpts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ interface NormalizedOpts extends Opts {
export function normalizeOpts(
babelOpts: Babel.PluginPass["opts"]
): NormalizedOpts {
const opts = babelOpts || Object.create(null);
const opts = babelOpts as Opts;
const normalized = {
include: [/\.module\.(?:scss|css)$/i],
identityObjectProxy: false,
identityObjectProxy:
typeof opts.identityObjectProxy === "boolean"
? opts.identityObjectProxy
: false,
};

if (Array.isArray(opts.include)) {
Expand All @@ -36,10 +39,6 @@ export function normalizeOpts(
);
}

if ([true, false].includes(opts.identityObjectProxy)) {
normalized.identityObjectProxy = opts.identityObjectProxy;
}

return normalized;
}

Expand Down
6 changes: 0 additions & 6 deletions packages/odyssey-babel-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ export function plugin({ types: t }: typeof Babel): Babel.PluginObj {

visitor: {
ImportDeclaration(path, state) {
if (state.opts === false) {
return;
}
const opts = normalizeOpts(state.opts);

const importer = state?.file?.opts?.filename;
Expand Down Expand Up @@ -71,9 +68,6 @@ export function plugin({ types: t }: typeof Babel): Babel.PluginObj {
},

CallExpression(path, state) {
if (state.opts === false) {
return;
}
const opts = normalizeOpts(state.opts);

const importer = state?.file?.opts?.filename;
Expand Down
4 changes: 2 additions & 2 deletions packages/odyssey-babel-preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"prepack": "yarn exec prepack"
},
"dependencies": {
"@babel/core": "^7.19.1",
"@babel/core": "^7.19.3",
"@babel/preset-env": "^7.19.1",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
Expand All @@ -26,7 +26,7 @@
"devDependencies": {
"@okta/odyssey-lifecycle": "^0.15.0",
"@okta/odyssey-typescript": "^0.15.0",
"@types/babel__core": "^7.1.15",
"@types/babel__core": "^7.1.19",
"typescript": "^4.8.3"
}
}
2 changes: 1 addition & 1 deletion packages/odyssey-postcss-preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"typescript": "^4.4.4"
},
"peerDependencies": {
"postcss": "^8.3.6"
"postcss": "^8.4.16"
}
}
4 changes: 2 additions & 2 deletions packages/odyssey-postcss-scss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"@okta/odyssey-typescript": "^0.15.0",
"@types/sass": "^1.16.1",
"jest": "^29.0.3",
"postcss": "^8.3.6",
"postcss": "^8.4.16",
"typescript": "^4.8.3"
},
"peerDependencies": {
"postcss": "^8.3.6"
"postcss": "^8.4.16"
}
}
3 changes: 2 additions & 1 deletion packages/odyssey-postcss-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
"@okta/odyssey-lifecycle": "^0.15.0",
"@okta/odyssey-typescript": "^0.15.0",
"jest": "^29.0.3",
"postcss": "^8.4.16",
"typescript": "^4.8.3"
},
"peerDependencies": {
"postcss": "^8.3.6"
"postcss": "^8.4.16"
}
}
5 changes: 2 additions & 3 deletions packages/odyssey-react-mui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"@okta/odyssey-design-tokens": "^0.15.0"
},
"devDependencies": {
"@babel/cli": "^7.18.10",
"@babel/core": "^7.19.1",
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@mui/icons-material": "^5.10.3",
Expand All @@ -43,7 +43,6 @@
"@types/jest-axe": "^3.5.1",
"@types/react": "^17.0.30",
"@types/react-dom": "^17.0.5",
"babel-jest": "^26.6.3",
"babel-plugin-import": "^1.13.5",
"eslint": "^7.27.0",
"jest": "^29.0.3",
Expand Down
5 changes: 2 additions & 3 deletions packages/odyssey-react-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"hoist-non-react-statics": "^3.3.2"
},
"devDependencies": {
"@babel/cli": "^7.18.10",
"@babel/core": "^7.19.1",
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"@okta/browserslist-config-odyssey": "^0.15.0",
"@okta/odyssey-babel-preset": "^0.15.0",
"@okta/odyssey-lifecycle": "^0.15.0",
Expand All @@ -35,7 +35,6 @@
"@types/hoist-non-react-statics": "^3.3.1",
"@types/react": "^17.0.30",
"@types/react-dom": "^17.0.5",
"babel-jest": "^26.6.3",
"eslint": "^7.27.0",
"jest": "^29.0.3",
"jest-environment-jsdom": "^29.0.3",
Expand Down
7 changes: 3 additions & 4 deletions packages/odyssey-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"choices.js": "^9.0.1"
},
"devDependencies": {
"@babel/cli": "^7.18.10",
"@babel/core": "^7.19.1",
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"@okta/browserslist-config-odyssey": "^0.15.0",
"@okta/odyssey-babel-preset": "^0.15.0",
"@okta/odyssey-lifecycle": "^0.15.0",
Expand All @@ -41,13 +41,12 @@
"@types/jest-axe": "^3.5.1",
"@types/react": "^17.0.30",
"@types/react-dom": "^17.0.5",
"babel-jest": "^26.6.3",
"chokidar": "^3.4.0",
"eslint": "^7.27.0",
"jest": "^29.0.3",
"jest-axe": "^5.0.1",
"jest-environment-jsdom": "^29.0.3",
"postcss": "^8.3.6",
"postcss": "^8.4.16",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"regenerator-runtime": "^0.13.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/odyssey-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"devDependencies": {
"@applitools/eyes-storybook": "^3.27.6",
"@babel/core": "^7.19.1",
"@babel/core": "^7.19.3",
"@mui/icons-material": "^5.10.3",
"@mui/material": "^5.10.5",
"@mui/utils": "^5.10.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/odyssey-stylelint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"devDependencies": {
"jest": "^29.0.3",
"jest-preset-stylelint": "^4.1.1",
"postcss": "^8.3.6",
"postcss": "^8.4.16",
"postcss-scss": "^4.0.0"
},
"peerDependencies": {
Expand Down
Loading

0 comments on commit 9740d6d

Please sign in to comment.