Skip to content

Commit

Permalink
refactor: deprecate defaultTransformerOptions in presets
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Dec 31, 2024
1 parent edeaa3f commit 99d3112
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 69 deletions.
16 changes: 5 additions & 11 deletions examples/example-app-monorepo/apps/app1/jest-isolated.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import type { Config } from 'jest';
import presets from 'jest-preset-angular/presets';
import type { JestConfigWithTsJest } from 'ts-jest';

import jestCfg from './jest.config';

export default {
...jestCfg,
transform: {
'^.+\\.(ts|js|mjs|html|svg)$': [
'jest-preset-angular',
{
...presets.defaultTransformerOptions,
isolatedModules: true,
},
],
},
} satisfies JestConfigWithTsJest;
...presets.createCjsPreset({
isolatedModules: true,
}),
} satisfies Config;
12 changes: 3 additions & 9 deletions examples/example-app-monorepo/libs/user/jest-isolated.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import jestCfg from './jest.config';

export default {
...jestCfg,
transform: {
'^.+\\.(ts|js|mjs|html|svg)$': [
'jest-preset-angular',
{
...presets.defaultTransformerOptions,
isolatedModules: true,
},
],
},
...presets.createCjsPreset({
isolatedModules: true,
}),
} satisfies JestConfigWithTsJest;
12 changes: 3 additions & 9 deletions examples/example-app-v17/jest-isolated.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import jestCfg from './jest.config';

export default {
...jestCfg,
transform: {
'^.+\\.(ts|js|mjs|html|svg)$': [
'jest-preset-angular',
{
...presets.defaultTransformerOptions,
isolatedModules: true,
},
],
},
...presets.createCjsPreset({
isolatedModules: true,
}),
} satisfies JestConfigWithTsJest;
12 changes: 3 additions & 9 deletions examples/example-app-v18/jest-isolated.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import jestCfg from './jest.config';

export default {
...jestCfg,
transform: {
'^.+\\.(ts|js|mjs|html|svg)$': [
'jest-preset-angular',
{
...presets.defaultTransformerOptions,
isolatedModules: true,
},
],
},
...presets.createCjsPreset({
isolatedModules: true,
}),
} satisfies JestConfigWithTsJest;
12 changes: 3 additions & 9 deletions examples/example-app-v19/jest-isolated.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import jestCfg from './jest.config';

export default {
...jestCfg,
transform: {
'^.+\\.(ts|js|mjs|html|svg)$': [
'jest-preset-angular',
{
...presets.defaultTransformerOptions,
isolatedModules: true,
},
],
},
...presets.createCjsPreset({
isolatedModules: true,
}),
} satisfies JestConfigWithTsJest;
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import jestCfg from './jest.config';

export default {
...jestCfg,
transform: {
'^.+\\.(ts|js|mjs|html|svg)$': [
'jest-preset-angular',
{
...presets.defaultTransformerOptions,
isolatedModules: true,
},
],
},
...presets.createCjsPreset({
isolatedModules: true,
}),
} satisfies JestConfigWithTsJest;
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import jestCfg from './jest.config';

export default {
...jestCfg,
transform: {
'^.+\\.(ts|js|mjs|html|svg)$': [
'jest-preset-angular',
{
...presets.defaultTransformerOptions,
isolatedModules: true,
},
],
},
...presets.createCjsPreset({
isolatedModules: true,
}),
} satisfies JestConfigWithTsJest;
15 changes: 11 additions & 4 deletions presets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@ const ngJestPresets = require('../build/presets');
module.exports = {
get defaults() {
console.warn(`
This preset is DEPRECATED and will be removed in the future.
This preset is DEPRECATED and will be removed in the next major release.
Please use "createCjsPreset" function instead. See documentation at https://thymikee.github.io/jest-preset-angular/docs/getting-started/presets#createcjspresetoptions
`);

return ngJestPresets.defaultPreset;
},
get defaultsESM() {
console.warn(`
This preset is DEPRECATED and will be removed in the future.
Please use "createCjsPreset" function instead. See documentation at https://thymikee.github.io/jest-preset-angular/docs/getting-started/presets#createesmpresetoptions
This preset is DEPRECATED and will be removed in the next major release.
Please use "createEsmPreset" function instead. See documentation at https://thymikee.github.io/jest-preset-angular/docs/getting-started/presets#createesmpresetoptions
`);

return ngJestPresets.defaultEsmPreset;
},
defaultTransformerOptions: ngJestPresets.defaultTransformerOptions,
get defaultTransformerOptions() {
console.warn(`
These options are DEPRECATED and will be removed in the next major release.
Please use "createCjsPreset" or "createEsmPreset" function instead. See documentation at https://thymikee.github.io/jest-preset-angular/docs/getting-started/presets
`);

return ngJestPresets.defaultTransformerOptions;
},
createCjsPreset: ngJestPresets.createCjsPreset,
createEsmPreset: ngJestPresets.createEsmPreset,
};

0 comments on commit 99d3112

Please sign in to comment.