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

Upgrade ts version and webpack version #184

Merged
merged 7 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ dist
lerna-debug.log
yerna.log

# awesome-typescript-loader
.awcache

# Testing
coverage
test-report.xml
Expand Down
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-184.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Upgrade typescript/webpack versions
links:
- https://github.com/palantir/conjure-typescript/pull/184
45 changes: 19 additions & 26 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,12 @@
module.exports = {
bail: false,
collectCoverage: false,
/**
* Here, we enable code coverage reporting for parts of your application that can be easily
* unit tested as well as critical code paths where logic errors are costly. Note that many aspects
* of an application's user interface are best verified using ETE or integration tests rather than
* unit tests. While Jest tests are very cheap to run in a jsdom environment, they might provide
* a false sense of security that features are properly guarded against regressions.
*/
collectCoverageFrom: [
"src/**/*.{ts,tsx}",
"!**/*.d.ts",
],
coveragePathIgnorePatterns: [
'src/**/*.{ts,tsx}',
'!**/*.d.ts',
],
coveragePathIgnorePatterns: [],
coverageThreshold: {
/**
* These thresholds are intentionally kept low so as not to impose undue burden when bootstrapping
* a project. They should be adjusted as necessary as a project matures.
*/
global: {
branches: 50,
functions: 50,
Expand All @@ -35,21 +23,26 @@ module.exports = {
},
},
globals: {
"ts-jest": {
/** This global is necessary for ts-jest to locate the compiler project config. */
tsConfigFile: "src/tsconfig.json",
'ts-jest': {
tsconfig: 'src/tsconfig.json',
},
},
moduleFileExtensions: ["js", "json", "ts", "tsx"],
// rootDir is set at the package level and assumed to be the package root
// setupFiles: ["<rootDir>/src/testBootstrap.js"],
testEnvironment: "jsdom",
testMatch: ["<rootDir>/src/**/__tests__/*.{ts,tsx}"],
moduleFileExtensions: [
'js',
'json',
'ts',
'tsx',
],
testEnvironment: 'jsdom',
testMatch: [
'<rootDir>/src/**/__tests__/*.{ts,tsx}',
],
transform: {
"^.+\\.(js|jsx|ts|tsx)$": "ts-jest",
'^.+\\.(js|jsx|ts|tsx)$': 'ts-jest',
},
transformIgnorePatterns: [
"/node_modules/(?!(lodash-es)/)",
'/node_modules/(?!(lodash-es)/)',
],
verbose: true,
};
preset: 'ts-jest/presets/js-with-ts',
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ran the jest migration script to update this file - it seems to work fine!

16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@
"@types/commander": "2.12.2",
"@types/download": "^6.2.2",
"@types/fs-extra": "^5.0.4",
"@types/jest": "^22.2.3",
"@types/jest": "^27.0.3",
"@types/lodash": "^4.14.117",
"@types/mkdirp": "^0.5.2",
"@types/nock": "^9.3.0",
"@types/node": "^16.11.7",
"@types/node-dir": "^0.0.30",
"@types/semver": "^5.5.0",
"@types/tempy": "^0.1.0",
"@types/yargs": "^11.1.2",
"awesome-typescript-loader": "^5.2.1",
"chai": "^4.2.0",
"jest": "^22.4.4",
"jest": "^27.0.3",
"karma": "^2.0.5",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
Expand All @@ -64,12 +64,14 @@
"mocha": "^5.2.0",
"node-dir": "^0.1.17",
"npm-run-all": "^4.1.3",
"spawn-sync": "^2.0.0",
"tempy": "^0.2.1",
"ts-jest": "^22.4.6",
"ts-jest": "^27.0.7",
"ts-loader": "^9.2.6",
"tslint": "^5.11.0",
"typescript": "~3.2.0",
"webpack": "^4.21.0",
"webpack-cli": "^3.1.2"
"typescript": "~4.4.4",
"webpack": "^5.64.1",
"webpack-cli": "^4.9.1"
},
"author": "Palantir Technologies, Inc.",
"license": "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions src/commands/generate/__tests__/cliTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ describe("generate command", () => {
expect(fs.existsSync(path.join(outDir, "node_modules/typescript/bin/tsc")));
});

jest.setTimeout(10000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we move this out of the test case? seems like other test cases still set the timeout explicitly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a similar issue as jestjs/jest#11543 it's simply ignored, I should probably spend more time looking into it

Copy link
Contributor Author

@matthieu-beteille matthieu-beteille Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lifted this up to the top level describe and removed from each individual test, are you ok with that?

it("generated code compiles", async () => {
jest.setTimeout(10000);
await generateCommand.handler({
_: ["generate", input, outDir],
packageName: "foo",
Expand Down Expand Up @@ -242,7 +242,7 @@ describe("generate command", () => {
const child = child_process.exec(command, { cwd });
child.on("error", reject);
child.on("exit", code => {
resolve(code);
resolve(code || 0);
});
});
}
Expand Down
19 changes: 10 additions & 9 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
devtool: false,
entry: "./src/conjureTypeScript.ts",
resolve: {
extensions: [ ".js", ".ts", ".json" ],
extensions: [".js", ".ts", ".json"],
},
output: {
path: path.resolve(__dirname, 'dist/bin'),
Expand All @@ -17,17 +17,18 @@ module.exports = {
rules: [
{
test: /\.ts$/,
loader: require.resolve("awesome-typescript-loader"),
options: {
configFileName: "./src/tsconfig.json",
useCache: true,
declaration: false
}
use: [
{
loader: 'ts-loader',
options: {
configFile: "./tsconfig.json",
}
}
],
}
]
},
plugins: [
new webpack.IgnorePlugin(/^electron$/),
new webpack.BannerPlugin({ banner: "#!/usr/bin/env node", raw: true})
new webpack.BannerPlugin({ banner: "#!/usr/bin/env node", raw: true })
],
};
Loading