* chore(angular): support angular 13 Support Angular 13 chore(angular): support ng 13 next 11 chore(angular): upgrade tslib dep chore(angular): update package and ng-packagr-lite executors to align with ng-packagr v13 chore(angular): update test snapshots with ts version fix(angular): buildable lib tsconfig transform test * chore(angular): sync ng-packagr changes to the package and ng-packagr-lite executors * chore(angular): add migrations * chore(angular): rxjs7 * feat(angular): check rxjs version to install * feat(angular): update jest resolver to resolve esm * chore(angular): fix version * chore(angular): support jest-preset-angular * fix(angular): tests * fix(angular): fix e2e tests and add .angular to gitignore * fix(angular): fix jest transformers ignore pattern * fix(angular): fix node test * fix(angular): fix workspace test * fix(angular): import marble utils from jasmine-marbles instead of @nrwl/angular/testing * feat(angular): update ngrx to 13.0.0-beta.;0 * fix(angular): temporarily skip test with pnpm * fix(angular): bump jest-preset-angular to fix jest performance issues * fix(angular): webpack-browser and server schema changes Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com> Co-authored-by: Jason Jean <jasonjean1993@gmail.com>
75 lines
2.0 KiB
TypeScript
75 lines
2.0 KiB
TypeScript
import { dirname, extname } from 'path';
|
|
import type defaultResolver from 'jest-resolve/build/defaultResolver';
|
|
|
|
interface ResolveOptions {
|
|
rootDir: string;
|
|
basedir: string;
|
|
paths: string[];
|
|
moduleDirectory: string[];
|
|
browser: boolean;
|
|
extensions: string[];
|
|
defaultResolver: typeof defaultResolver;
|
|
}
|
|
|
|
let compilerSetup;
|
|
let ts;
|
|
|
|
function getCompilerSetup(rootDir: string) {
|
|
const tsConfigPath =
|
|
ts.findConfigFile(rootDir, ts.sys.fileExists, 'tsconfig.spec.json') ||
|
|
ts.findConfigFile(rootDir, ts.sys.fileExists, 'tsconfig.test.json') ||
|
|
ts.findConfigFile(rootDir, ts.sys.fileExists, 'tsconfig.jest.json');
|
|
|
|
if (!tsConfigPath) {
|
|
console.error(
|
|
`Cannot locate a tsconfig.spec.json. Please create one at ${rootDir}/tsconfig.spec.json`
|
|
);
|
|
}
|
|
|
|
const readResult = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
|
|
const config = ts.parseJsonConfigFileContent(
|
|
readResult.config,
|
|
ts.sys,
|
|
dirname(tsConfigPath)
|
|
);
|
|
const compilerOptions = config.options;
|
|
const host = ts.createCompilerHost(compilerOptions, true);
|
|
return { compilerOptions, host };
|
|
}
|
|
|
|
module.exports = function (path: string, options: ResolveOptions) {
|
|
const ext = extname(path);
|
|
if (
|
|
ext === '.css' ||
|
|
ext === '.scss' ||
|
|
ext === '.sass' ||
|
|
ext === '.less' ||
|
|
ext === '.styl'
|
|
) {
|
|
return require.resolve('identity-obj-proxy');
|
|
}
|
|
// Try to use the defaultResolver
|
|
try {
|
|
return options.defaultResolver(path, {
|
|
...options,
|
|
packageFilter: (pkg) => ({
|
|
...pkg,
|
|
main: pkg.main || pkg.es2015 || pkg.module,
|
|
}),
|
|
});
|
|
} catch (e) {
|
|
if (
|
|
path === 'jest-sequencer-@jest/test-sequencer' ||
|
|
path === '@jest/test-sequencer'
|
|
) {
|
|
return;
|
|
}
|
|
// Fallback to using typescript
|
|
ts = ts || require('typescript');
|
|
compilerSetup = compilerSetup || getCompilerSetup(options.rootDir);
|
|
const { compilerOptions, host } = compilerSetup;
|
|
return ts.resolveModuleName(path, options.basedir, compilerOptions, host)
|
|
.resolvedModule.resolvedFileName;
|
|
}
|
|
};
|