-
-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(custom-esbuild): allow providing ESBuild plugins (#1536)
- Loading branch information
Showing
86 changed files
with
4,054 additions
and
4,168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
examples/custom-esbuild/sanity-esbuild-app-esm/.editorconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# 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 | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# 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 | ||
speed-measure-plugin.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 | ||
/.angular/cache | ||
/.sass-cache | ||
/connect.lock | ||
/coverage | ||
/libpeerconnection.log | ||
npm-debug.log | ||
yarn-error.log | ||
testem.log | ||
/typings | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db |
140 changes: 140 additions & 0 deletions
140
examples/custom-esbuild/sanity-esbuild-app-esm/angular.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"sanity-esbuild-app-esm": { | ||
"projectType": "application", | ||
"schematics": { | ||
"@schematics/angular:component": { | ||
"style": "scss" | ||
} | ||
}, | ||
"root": "", | ||
"sourceRoot": "src", | ||
"prefix": "app", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-builders/custom-esbuild:application", | ||
"options": { | ||
"plugins": ["esbuild/define-text-plugin.js"], | ||
"outputPath": "dist/sanity-esbuild-app-esm", | ||
"index": "src/index.html", | ||
"browser": "src/main.ts", | ||
"polyfills": ["zone.js"], | ||
"tsConfig": "tsconfig.app.json", | ||
"inlineStyleLanguage": "scss", | ||
"assets": ["src/favicon.ico", "src/assets"], | ||
"styles": ["src/styles.scss"], | ||
"scripts": [] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"budgets": [ | ||
{ | ||
"type": "initial", | ||
"maximumWarning": "500kb", | ||
"maximumError": "1mb" | ||
}, | ||
{ | ||
"type": "anyComponentStyle", | ||
"maximumWarning": "2kb", | ||
"maximumError": "4kb" | ||
} | ||
], | ||
"outputHashing": "all" | ||
}, | ||
"esm": { | ||
"plugins": ["esbuild/define-text-plugin.js"] | ||
}, | ||
"cjs": { | ||
"plugins": ["esbuild/define-text-plugin.cjs"] | ||
}, | ||
"tsEsm": { | ||
"plugins": ["esbuild/define-text-plugin.ts"] | ||
} | ||
}, | ||
"defaultConfiguration": "production" | ||
}, | ||
"serve": { | ||
"builder": "@angular-builders/custom-esbuild:dev-server", | ||
"options": { | ||
"forceEsbuild": true, | ||
"port": 5007 | ||
}, | ||
"configurations": { | ||
"production": { | ||
"buildTarget": "sanity-esbuild-app-esm:build:production" | ||
}, | ||
"esm": { | ||
"buildTarget": "sanity-esbuild-app-esm:build:esm", | ||
"middlewares": ["esbuild/send-hello-middleware.js"] | ||
}, | ||
"cjs": { | ||
"buildTarget": "sanity-esbuild-app-esm:build:cjs", | ||
"middlewares": ["esbuild/send-hello-middleware.cjs"] | ||
}, | ||
"tsEsm": { | ||
"buildTarget": "sanity-esbuild-app-esm:build:tsEsm", | ||
"middlewares": ["esbuild/send-hello-middleware.ts"] | ||
} | ||
}, | ||
"defaultConfiguration": "cjs" | ||
}, | ||
"test": { | ||
"builder": "@angular-devkit/build-angular:karma", | ||
"options": { | ||
"polyfills": ["zone.js", "zone.js/testing"], | ||
"tsConfig": "tsconfig.spec.json", | ||
"karmaConfig": "karma.conf.cjs", | ||
"inlineStyleLanguage": "scss", | ||
"assets": ["src/favicon.ico", "src/assets"], | ||
"styles": ["src/styles.scss"], | ||
"scripts": [] | ||
} | ||
}, | ||
"e2e": { | ||
"builder": "@cypress/schematic:cypress", | ||
"options": { | ||
"devServerTarget": "sanity-esbuild-app-esm:serve", | ||
"browser": "chrome", | ||
"port": 4226 | ||
}, | ||
"configurations": { | ||
"production": { | ||
"devServerTarget": "sanity-esbuild-app-esm:serve:production" | ||
}, | ||
"esm": { | ||
"devServerTarget": "sanity-esbuild-app-esm:serve:esm" | ||
}, | ||
"cjs": { | ||
"devServerTarget": "sanity-esbuild-app-esm:serve:cjs" | ||
}, | ||
"tsEsm": { | ||
"devServerTarget": "sanity-esbuild-app-esm:serve:tsEsm" | ||
} | ||
}, | ||
"defaultConfiguration": "esm" | ||
}, | ||
"cypress-run": { | ||
"builder": "@cypress/schematic:cypress", | ||
"options": { | ||
"devServerTarget": "sanity-esbuild-app-esm:serve" | ||
}, | ||
"configurations": { | ||
"production": { | ||
"devServerTarget": "sanity-esbuild-app-esm:serve:production" | ||
} | ||
} | ||
}, | ||
"cypress-open": { | ||
"builder": "@cypress/schematic:cypress", | ||
"options": { | ||
"watch": true, | ||
"headless": false | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
examples/custom-esbuild/sanity-esbuild-app-esm/cypress.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from 'cypress'; | ||
|
||
export default defineConfig({ | ||
video: false, | ||
screenshotOnRunFailure: false, | ||
e2e: { | ||
setupNodeEvents(on, config) {}, | ||
specPattern: 'e2e/src/**/*.e2e-spec.ts', | ||
baseUrl: 'http://localhost:5001', | ||
supportFile: false, | ||
}, | ||
}); |
23 changes: 23 additions & 0 deletions
23
examples/custom-esbuild/sanity-esbuild-app-esm/e2e/src/app.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { AppPage } from './app.po'; | ||
|
||
describe('workspace-project App', () => { | ||
let page: AppPage; | ||
|
||
beforeEach(() => { | ||
page = new AppPage(); | ||
}); | ||
|
||
it('should display welcome message', () => { | ||
page.navigateTo(); | ||
page | ||
.getTitle() | ||
.should( | ||
'have.text', | ||
'Welcome to sanity-esbuild-app-esm: This text is provided during the compilation!' | ||
); | ||
}); | ||
|
||
it('should display text from custom middleware', () => { | ||
cy.visit('/send-hello').get('h1').should('have.text', 'Hello text from middleware!'); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
examples/custom-esbuild/sanity-esbuild-app-esm/e2e/src/app.po.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class AppPage { | ||
navigateTo() { | ||
return cy.visit('/'); | ||
} | ||
|
||
getTitle() { | ||
return cy.get('app-root h1'); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
examples/custom-esbuild/sanity-esbuild-app-esm/e2e/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"include": ["**/*.ts"], | ||
"compilerOptions": { | ||
"sourceMap": false, | ||
"types": ["cypress"] | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/custom-esbuild/sanity-esbuild-app-esm/esbuild/define-text-plugin.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const defineTextPlugin = { | ||
name: 'define-text', | ||
setup(build) { | ||
const options = build.initialOptions; | ||
options.define.buildText = JSON.stringify('This text is provided during the compilation'); | ||
}, | ||
}; | ||
|
||
module.exports = defineTextPlugin; |
9 changes: 9 additions & 0 deletions
9
examples/custom-esbuild/sanity-esbuild-app-esm/esbuild/define-text-plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const defineTextPlugin = { | ||
name: 'define-text', | ||
setup(build) { | ||
const options = build.initialOptions; | ||
options.define.buildText = JSON.stringify('This text is provided during the compilation'); | ||
}, | ||
}; | ||
|
||
export default defineTextPlugin; |
11 changes: 11 additions & 0 deletions
11
examples/custom-esbuild/sanity-esbuild-app-esm/esbuild/define-text-plugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { Plugin, PluginBuild } from 'esbuild'; | ||
|
||
const defineTextPlugin: Plugin = { | ||
name: 'define-text', | ||
setup(build: PluginBuild) { | ||
const options = build.initialOptions; | ||
options.define!['buildText'] = JSON.stringify('This text is provided during the compilation'); | ||
}, | ||
}; | ||
|
||
export default defineTextPlugin; |
9 changes: 9 additions & 0 deletions
9
examples/custom-esbuild/sanity-esbuild-app-esm/esbuild/send-hello-middleware.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const sendHelloMiddleware = (req, res, next) => { | ||
if (req.url === '/send-hello') { | ||
res.end('<h1>Hello text from middleware!</h1>'); | ||
} else { | ||
next(); | ||
} | ||
}; | ||
|
||
module.exports = sendHelloMiddleware; |
9 changes: 9 additions & 0 deletions
9
examples/custom-esbuild/sanity-esbuild-app-esm/esbuild/send-hello-middleware.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const sendHelloMiddleware = (req, res, next) => { | ||
if (req.url === '/send-hello') { | ||
res.end('<h1>Hello text from middleware!</h1>'); | ||
} else { | ||
next(); | ||
} | ||
}; | ||
|
||
export default sendHelloMiddleware; |
11 changes: 11 additions & 0 deletions
11
examples/custom-esbuild/sanity-esbuild-app-esm/esbuild/send-hello-middleware.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { NextHandleFunction } from 'connect'; | ||
|
||
const sendHelloMiddleware: NextHandleFunction = (req, res, next) => { | ||
if (req.url === '/send-hello') { | ||
res.end('<h1>Hello text from middleware!</h1>'); | ||
} else { | ||
next(); | ||
} | ||
}; | ||
|
||
export default sendHelloMiddleware; |
50 changes: 50 additions & 0 deletions
50
examples/custom-esbuild/sanity-esbuild-app-esm/karma.conf.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Karma configuration file, see link for more information | ||
// https://karma-runner.github.io/1.0/config/configuration-file.html | ||
|
||
const path = require('path'); | ||
process.env.CHROME_BIN = require('puppeteer').executablePath(); | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
basePath: '', | ||
frameworks: ['jasmine', '@angular-devkit/build-angular'], | ||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-jasmine-html-reporter'), | ||
require('karma-coverage'), | ||
require('@angular-devkit/build-angular/plugins/karma'), | ||
], | ||
client: { | ||
clearContext: false, // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
coverageReporter: { | ||
dir: path.join(__dirname, 'coverage', 'append-webpack-plugins'), | ||
subdir: '.', | ||
reporters: [ | ||
{ type: 'text-summary' }, | ||
{ type: 'html', subdir: 'html' }, | ||
{ type: 'lcovonly' }, | ||
{ type: 'json' }, | ||
], | ||
}, | ||
reporters: ['progress', 'kjhtml', 'coverage'], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
flags: ['--disable-translate', '--disable-extensions'], | ||
browsers: ['Chrome'], | ||
browserConsoleLogOptions: { | ||
terminal: false, | ||
}, | ||
customLaunchers: { | ||
ChromeHeadlessCI: { | ||
base: 'ChromeHeadless', | ||
flags: ['--no-sandbox', '--disable-gpu', '--disable-translate', '--disable-extensions'], | ||
}, | ||
}, | ||
singleRun: true, | ||
restartOnFileChange: true, | ||
}); | ||
}; |
Oops, something went wrong.