Skip to content

Commit

Permalink
fix: allow ESM preset to be used in monorepo structure (#942)
Browse files Browse the repository at this point in the history
Because `<rootDir>` is not workspace-root directory when it has a monorepo structure like Nrwl/Nx, `<rootDir>/node_modules` is not compatible with that.
  • Loading branch information
lacolaco authored Jun 2, 2021
1 parent 0c37d6f commit b402e28
Show file tree
Hide file tree
Showing 49 changed files with 17,890 additions and 2 deletions.
16 changes: 16 additions & 0 deletions examples/example-app-v12-monorepo/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
45 changes: 45 additions & 0 deletions examples/example-app-v12-monorepo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out

# dependencies
/node_modules

# profiling files
chrome-profiler-events*.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
31 changes: 31 additions & 0 deletions examples/example-app-v12-monorepo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Example

This is an example app using `jest-preset-angular`. It is not supposed to be a boilerplate for an Angular app tested with jest, but could be used as a rough reference for configuration.

The jest configuration itself is located in the `projects/<appName>/jest.config.js`.

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.0.0.

## Running unit tests

Run `yarn test` or `npm test` to execute the unit tests via [Jest](https://jestjs.io).

## Running end-to-end tests

End-to-end are not setup in this project.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
173 changes: 173 additions & 0 deletions examples/example-app-v12-monorepo/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"cli": {
"packageManager": "npm"
},
"newProjectRoot": "projects",
"projects": {
"app1": {
"projectType": "application",
"schematics": {
"@schematics/angular:application": {
"strict": true
}
},
"root": "projects/app1",
"sourceRoot": "projects/app1/src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/app1",
"index": "projects/app1/src/index.html",
"main": "projects/app1/src/main.ts",
"polyfills": "projects/app1/src/polyfills.ts",
"tsConfig": "projects/app1/tsconfig.app.json",
"assets": [
"projects/app1/src/favicon.ico",
"projects/app1/src/assets"
],
"styles": [
"projects/app1/src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "projects/app1/src/environments/environment.ts",
"with": "projects/app1/src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "app1:build:production"
},
"development": {
"browserTarget": "app1:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "app1:build"
}
}
}
},
"app2": {
"projectType": "application",
"schematics": {
"@schematics/angular:application": {
"strict": true
}
},
"root": "projects/app2",
"sourceRoot": "projects/app2/src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/app2",
"index": "projects/app2/src/index.html",
"main": "projects/app2/src/main.ts",
"polyfills": "projects/app2/src/polyfills.ts",
"tsConfig": "projects/app2/tsconfig.app.json",
"assets": [
"projects/app2/src/favicon.ico",
"projects/app2/src/assets"
],
"styles": [
"projects/app2/src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "projects/app2/src/environments/environment.ts",
"with": "projects/app2/src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "app2:build:production"
},
"development": {
"browserTarget": "app2:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "app2:build"
}
}
}
}
},
"defaultProject": "app1"
}
Loading

0 comments on commit b402e28

Please sign in to comment.