diff --git a/.circleci/config.yml b/.circleci/config.yml index dc63f82233..b1d8bb99f4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -281,7 +281,6 @@ jobs: steps: - run: git checkout << parameters.branch >> - run: git pull - - run: sudo npm i -g ts-node @types/node - run: name: "Authenticate with registry" command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc @@ -404,20 +403,20 @@ workflows: # Triggered by push to master or topic branches build_test: jobs: - # - unit_test_esm: - # <<: *filter_ignore_develop_release - # name: unit_test_esm_chrome - # npm_command: "test-chrome" - # - unit_test_esm: - # <<: *filter_ignore_develop_release - # name: unit_test_esm_firefox - # npm_command: "test-firefox" - # coverage: false - # - unit_test_esm: - # <<: *filter_ignore_develop_release - # name: unit_test_esm_node - # npm_command: "test-node" - # coverage: false + - unit_test_esm: + <<: *filter_ignore_develop_release + name: unit_test_esm_chrome + npm_command: "test-chrome" + - unit_test_esm: + <<: *filter_ignore_develop_release + name: unit_test_esm_firefox + npm_command: "test-firefox" + coverage: false + - unit_test_esm: + <<: *filter_ignore_develop_release + name: unit_test_esm_node + npm_command: "test-node" + coverage: false - unit_test_cjs: <<: *filter_ignore_develop_release npm_command: "test-node" @@ -427,34 +426,34 @@ workflows: # npm_command: "test-262" # coverage: false # submodules: true - # - lint_packages: - # <<: *filter_ignore_develop_release - # - benchmark_playwright: - # <<: *filter_ignore_develop_release - # - e2e_playwright: - # <<: *filter_ignore_develop_release - # name: jit-webpack-conventions-ts - # path: "examples/jit-webpack-conventions-ts" - # requires: - # - lint_packages # not a real requirement but forces long-running jobs to go first - # - e2e_playwright: - # <<: *filter_ignore_develop_release - # name: jit-webpack-vanilla-ts - # path: "examples/jit-webpack-vanilla-ts" - # requires: - # - lint_packages # not a real requirement but forces long-running jobs to go first + - lint_packages: + <<: *filter_ignore_develop_release + - benchmark_playwright: + <<: *filter_ignore_develop_release + - e2e_playwright: + <<: *filter_ignore_develop_release + name: jit-webpack-conventions-ts + path: "examples/jit-webpack-conventions-ts" + requires: + - lint_packages # not a real requirement but forces long-running jobs to go first + - e2e_playwright: + <<: *filter_ignore_develop_release + name: jit-webpack-vanilla-ts + path: "examples/jit-webpack-vanilla-ts" + requires: + - lint_packages # not a real requirement but forces long-running jobs to go first - merge_and_dist: <<: *filter_only_master name: merge_and_dist_master requires: - # - unit_test_esm_chrome - # - unit_test_esm_firefox - # - unit_test_esm_node + - unit_test_esm_chrome + - unit_test_esm_firefox + - unit_test_esm_node - unit_test_cjs #- test_test262 - # - lint_packages - # - jit-webpack-conventions-ts - # - jit-webpack-vanilla-ts + - lint_packages + - jit-webpack-conventions-ts + - jit-webpack-vanilla-ts from: master to: develop channel: dev @@ -464,13 +463,13 @@ workflows: <<: *filter_only_topic name: merge_and_dist_topic requires: - # - unit_test_esm_chrome - # - unit_test_esm_firefox - # - unit_test_esm_node + - unit_test_esm_chrome + - unit_test_esm_firefox + - unit_test_esm_node - unit_test_cjs - # - lint_packages - # - jit-webpack-conventions-ts - # - jit-webpack-vanilla-ts + - lint_packages + - jit-webpack-conventions-ts + - jit-webpack-vanilla-ts from: master to: develop channel: dev diff --git a/.eslintignore b/.eslintignore index 7faa7cb6c7..194e6bc48e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ dist node_modules .eslintrc.cjs +scripts/*.js diff --git a/examples/1kcomponents/package.json b/examples/1kcomponents/package.json index 301ab32ae8..161a72d8c2 100644 --- a/examples/1kcomponents/package.json +++ b/examples/1kcomponents/package.json @@ -9,7 +9,7 @@ "version": "0.8.0", "scripts": { "build": "webpack --config webpack.config.js", - "serve": "node ../../node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js" + "serve": "node ../../node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js" }, "dependencies": { "@aurelia/kernel": "2.0.0-alpha.10", diff --git a/examples/doc-example/package.json b/examples/doc-example/package.json index a8138ff179..41f28d2e89 100644 --- a/examples/doc-example/package.json +++ b/examples/doc-example/package.json @@ -35,8 +35,8 @@ "start": "webpack-dev-server", "build": "rimraf dist && webpack --mode=production", "watch": "webpack-dev-server", - "serve": "node ./node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js", - "build-serve": "rimraf dist && webpack --mode=production && node ./node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js", + "serve": "node ./node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js", + "build-serve": "rimraf dist && webpack --mode=production && node ./node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js", "now": "rimraf dist && webpack --config webpack.config.js && cd dist && now && cd .." }, "engines": { diff --git a/examples/fractals-tree/package.json b/examples/fractals-tree/package.json index 70f1e4662c..e9c21f254b 100644 --- a/examples/fractals-tree/package.json +++ b/examples/fractals-tree/package.json @@ -9,7 +9,7 @@ "version": "0.8.0", "scripts": { "build": "webpack --config webpack.config.js", - "serve": "node ../../node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js" + "serve": "node ../../node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js" }, "dependencies": { "@aurelia/kernel": "2.0.0-alpha.10", diff --git a/examples/navigation-skeleton/package.json b/examples/navigation-skeleton/package.json index 6537781d13..291ba5741f 100644 --- a/examples/navigation-skeleton/package.json +++ b/examples/navigation-skeleton/package.json @@ -5,8 +5,8 @@ "scripts": { "watch": "webpack-dev-server", "build": "rimraf dist && webpack --config webpack.config.js", - "serve": "node ./node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js", - "build-serve": "rimraf dist && webpack --config webpack.config.js && node ./node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js", + "serve": "node ./node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js", + "build-serve": "rimraf dist && webpack --config webpack.config.js && node ./node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js", "now": "rimraf dist && webpack --config webpack.config.js && cd dist && now && cd .." }, "dependencies": { diff --git a/examples/rainbow-spiral/package.json b/examples/rainbow-spiral/package.json index f1086c427c..e08073d5d3 100644 --- a/examples/rainbow-spiral/package.json +++ b/examples/rainbow-spiral/package.json @@ -9,7 +9,7 @@ "version": "0.8.0", "scripts": { "build": "webpack --config webpack.config.js", - "serve": "node ../../node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js" + "serve": "node ../../node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js" }, "dependencies": { "@aurelia/kernel": "2.0.0-alpha.10", diff --git a/examples/sierpinski-triangle/package.json b/examples/sierpinski-triangle/package.json index 6ff2fe3c16..0d7b85f4ab 100644 --- a/examples/sierpinski-triangle/package.json +++ b/examples/sierpinski-triangle/package.json @@ -9,7 +9,7 @@ "version": "0.8.0", "scripts": { "build": "webpack --config webpack.config.js", - "serve": "node ../../node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js" + "serve": "node ../../node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js" }, "dependencies": { "@aurelia/kernel": "2.0.0-alpha.10", diff --git a/package.json b/package.json index ef8fa387dc..46d345b258 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "build:release": "lage run build --scope aurelia --scope au --scope @aurelia/a* --scope @aurelia/b* --scope @aurelia/f* --scope @aurelia/h* --scope @aurelia/i* --scope @aurelia/k* --scope @aurelia/m* --scope @aurelia/p* --scope @aurelia/r* --scope @aurelia/s* --scope @aurelia/t* --scope @aurelia/v* --scope @aurelia/w* --no-cache --verbose --no-deps", "postbuild:release": "npm run clean:tsconfig-build-cache", "build:release:full": "npm run build:release && npm run change-tsconfigs:invert && npm run build:release && npm run change-tsconfigs:restore", + "build:release-script": "tsc --project scripts/tsconfig.release-script.json", "change-package-refs:dev": "ts-node -P tsconfig.json scripts/change-package-refs.ts dev", "change-package-refs:release": "ts-node -P tsconfig.json scripts/change-package-refs.ts release", "clean": "rimraf dist packages/*/dist packages-cjs/*/dist test/*/dist test/benchmarking-apps/*/dist examples/*/dist", @@ -76,8 +77,8 @@ "change-tsconfigs:restore": "ts-node -P tsconfig.json scripts/change-tsconfigs.ts restore", "prepare-release": "ts-node -P tsconfig.json scripts/prepare-release.ts", "generate-native-modules": "ts-node -P tsconfig.json scripts/generate-native-modules.ts", - "publish:dev": "ts-node -P tsconfig.json scripts/publish.ts dev --transpile-only", - "publish:latest": "ts-node -P tsconfig.json scripts/publish.ts latest --transpile-only", + "publish:dev": "node scripts/publish.js dev", + "publish:latest": "node scripts/publish.js latest", "bump-version:dev": "ts-node -P tsconfig.json scripts/bump-version.ts dev", "bump-version:latest": "ts-node -P tsconfig.json scripts/bump-version.ts latest", "check-dependencies": "ts-node -P tsconfig.json scripts/check-dependencies.ts", diff --git a/packages/http-server/bin/cli.js b/packages/http-server/bin/cli.js index 6c3cf8b018..8adb3ad3a9 100755 --- a/packages/http-server/bin/cli.js +++ b/packages/http-server/bin/cli.js @@ -1,4 +1,4 @@ #!/usr/bin/env node /* eslint-disable import/extensions */ -import '../dist/bundle/cli.js'; +import '../dist/esm/cli.js'; diff --git a/packages/http-server/rollup.config.js b/packages/http-server/rollup.config.js index 8aabf2623e..eb64e065a5 100644 --- a/packages/http-server/rollup.config.js +++ b/packages/http-server/rollup.config.js @@ -29,7 +29,7 @@ export default [ external: Object.keys(pkg.dependencies).concat('os', 'path', 'fs', 'http', 'https', 'http2', 'url', 'stream'), output: [ { - file: 'dist/bundle/cli.js', + file: 'dist/esm/cli.js', format: 'es', sourcemap: true }, diff --git a/scripts/generate-native-modules.ts b/scripts/generate-native-modules.ts index b63568892e..0c9e05085b 100644 --- a/scripts/generate-native-modules.ts +++ b/scripts/generate-native-modules.ts @@ -3,12 +3,12 @@ // example: // import {} from '@aurelia/kernel' // -> -// import {} from '../../kernel/dist/bundle/index.js' +// import {} from '../../kernel/dist/esm/index.js' // this works with CDN well, though it wouldn't have the proper sourcemap // todo: consider make this step part of the rollup build // ------------------------ import * as ts from 'typescript'; -import { File, getFiles } from './files'; +import { getFiles } from './files'; import { createLogger } from './logger'; import project from './project'; import * as path from 'path'; @@ -21,9 +21,7 @@ const log = createLogger('generate-native-modules'); for (const pkg of packages) { const distPath = path.join(pkg.path, 'dist'); - // old bundling code: const esmPath = path.join(distPath, 'esm'); - // const bundlePath = path.join(distPath, 'bundle'); const nativeModulesPath = path.join(distPath, 'native-modules'); log.info(`Processing '${esmPath}'`); diff --git a/scripts/package.json.js b/scripts/package.json.js new file mode 100644 index 0000000000..e98f2fc3a8 --- /dev/null +++ b/scripts/package.json.js @@ -0,0 +1,51 @@ +/* eslint-disable */ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.savePackageJson = exports.loadPackageJson = void 0; +const fs_1 = require("fs"); +const path_1 = require("path"); +const project_1 = __importDefault(require("./project")); +/** + * Reads and parses the content of a package.json file + * + * @param pathSegments - The path segments of the folder where the package.json is located, relative to the root of the project + */ +async function loadPackageJson(...pathSegments) { + const path = path_1.join(project_1.default.path, ...pathSegments, 'package.json'); + return new Promise((resolve, reject) => { + fs_1.readFile(path, (err, data) => { + if (err) { + reject(err); + } + if (!data) { + throw new Error(`Empty file: ${path}`); + } + const str = data.toString('utf8'); + const json = JSON.parse(str); + resolve(json); + }); + }); +} +exports.loadPackageJson = loadPackageJson; +/** + * Stringifies and writes out the content of a package.json file + * + * @param pkg - The package.json as an object + * @param pathSegments - The path segments of the folder where the package.json is located, relative to the root of the project + */ +async function savePackageJson(pkg, ...pathSegments) { + const path = path_1.join(project_1.default.path, ...pathSegments, 'package.json'); + return new Promise((resolve, reject) => { + const str = JSON.stringify(pkg, null, 2); + fs_1.writeFile(path, str, { encoding: 'utf8' }, (err) => { + if (err) { + reject(err); + } + resolve(); + }); + }); +} +exports.savePackageJson = savePackageJson; diff --git a/scripts/package.json.ts b/scripts/package.json.ts index 09097be302..1ac59944ce 100644 --- a/scripts/package.json.ts +++ b/scripts/package.json.ts @@ -1,4 +1,3 @@ -// @ts-nocheck import { readFile, writeFile } from 'fs'; import { join } from 'path'; import project from './project'; diff --git a/scripts/project.js b/scripts/project.js new file mode 100644 index 0000000000..262fb90e52 --- /dev/null +++ b/scripts/project.js @@ -0,0 +1,101 @@ +/* eslint-disable */ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const path_1 = require("path"); +const packageJson = __importStar(require("../package.json")); +// TODO: generate this file automatically +const rootPath = process.cwd(); +const testApps = [ + 'jit-webpack-conventions-ts', + 'jit-webpack-vanilla-ts' +]; +function camelCase(input) { + const parts = input.split('-'); + return `${parts[0]}${parts.slice(1).map(x => `${x[0].toUpperCase()}${x.slice(1)}`).join('')}`; +} +exports.default = { + 'path': rootPath, + 'pkg': packageJson, + '.circleci': { + 'path': path_1.join(rootPath, '.circleci') + }, + '.vscode': { + 'path': path_1.join(rootPath, '.vscode') + }, + 'changelog': { + 'path': path_1.join(rootPath, 'docs', 'CHANGELOG.md') + }, + 'coverage': { + 'path': path_1.join(rootPath, 'coverage') + }, + 'dist': { + 'path': path_1.join(rootPath, 'dist') + }, + 'docs': { + 'path': path_1.join(rootPath, 'docs') + }, + 'examples': testApps.reduce((acc, app) => { + acc[app] = { + 'path': path_1.join(rootPath, 'examples', app) + }; + return acc; + }, {}), + 'node_modules': { + 'path': path_1.join(rootPath, 'node_modules') + }, + 'packages': packageJson.workspaces.map(p => { + const parts = p.split('/'); + const kebabName = parts[parts.length - 1]; + const camelName = camelCase(kebabName); + const folder = parts.slice(0, -1).join('/'); + const path = path_1.join(rootPath, p); + const nodeModules = path_1.join(path, 'node_modules'); + const coverage = path_1.join(rootPath, 'coverage', kebabName); + const tsconfig = path_1.join(path, 'tsconfig.json'); + const changelog = path_1.join(path, 'CHANGELOG.md'); + const srcPath = path_1.join(path, 'src'); + const src = { + path: srcPath, + entry: path_1.join(srcPath, 'index.ts'), + }; + const name = { + kebab: kebabName, + camel: camelName, + npm: kebabName === 'aurelia' + ? 'aurelia' + : kebabName === 'au' + ? 'au' + : `@aurelia/${kebabName}` + }; + return { path, folder, nodeModules, coverage, tsconfig, changelog, src, name }; + }), + 'scripts': { + 'path': path_1.join(rootPath, 'scripts'), + 'tsconfig.test': path_1.join(rootPath, 'scripts', 'tsconfig.test.json') + }, + 'test': { + 'path': path_1.join(rootPath, 'test'), + }, + 'package.json': { + 'path': path_1.join(rootPath, 'package.json') + }, +}; diff --git a/scripts/project.ts b/scripts/project.ts index 4e3fcd9d4e..1a38571728 100644 --- a/scripts/project.ts +++ b/scripts/project.ts @@ -1,4 +1,3 @@ -// @ts-nocheck import { join } from 'path'; import * as packageJson from '../package.json'; diff --git a/scripts/publish.js b/scripts/publish.js new file mode 100644 index 0000000000..0215de5c73 --- /dev/null +++ b/scripts/publish.js @@ -0,0 +1,27 @@ +/* eslint-disable */ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const package_json_1 = require("./package.json"); +const project_1 = __importDefault(require("./project")); +const child_process_1 = require("child_process"); +const path_1 = require("path"); +(async function () { + const [, , channel /* dev or latest */] = process.argv; + for (const { name, folder } of project_1.default.packages + .filter(p => !p.name.kebab.includes('_') + && p.folder.includes('packages'))) { + console.log(`publishing [${channel}] ${path_1.join(folder, name.kebab)}`); + const pkg = await package_json_1.loadPackageJson(folder, name.kebab); + if (pkg.private) { + continue; + } + child_process_1.execSync(`cd ${path_1.join(folder, name.kebab)} && npm run publish:${channel}`); + } + console.log('Done.'); +})().catch(err => { + console.error(err); + process.exit(1); +}); diff --git a/scripts/publish.ts b/scripts/publish.ts index dd7588ad53..f25dce41db 100644 --- a/scripts/publish.ts +++ b/scripts/publish.ts @@ -1,14 +1,10 @@ -// @ts-nocheck -// import { createLogger } from './logger'; import { loadPackageJson } from './package.json'; import project from './project'; import { execSync } from 'child_process'; import { join } from 'path'; -// const log = createLogger('publish'); - (async function (): Promise { - const [, , channel/* dev/latest */] = process.argv; + const [, , channel/* dev or latest */] = process.argv; for (const { name, folder } of project.packages @@ -17,7 +13,7 @@ import { join } from 'path'; && p.folder.includes('packages') ) ) { - console.log(`publishing`); + console.log(`publishing [${channel}] ${join(folder, name.kebab)}`); const pkg = await loadPackageJson(folder, name.kebab); if (pkg.private) { continue; diff --git a/scripts/tsconfig.release-script.json b/scripts/tsconfig.release-script.json new file mode 100644 index 0000000000..2b0115aacf --- /dev/null +++ b/scripts/tsconfig.release-script.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "experimentalDecorators": true, + "esModuleInterop": true, + "module": "commonjs", + "moduleResolution": "node", + "target": "es2018", + "lib": ["esnext"], + "resolveJsonModule": true, + "skipLibCheck": true + }, + "include": [ + "project.ts", + "package.json.ts", + "publish.ts", + ] +} diff --git a/test/benchmarking-apps/aurelia2-npm/package.json b/test/benchmarking-apps/aurelia2-npm/package.json index 090cc9946c..235063eb7b 100644 --- a/test/benchmarking-apps/aurelia2-npm/package.json +++ b/test/benchmarking-apps/aurelia2-npm/package.json @@ -7,7 +7,7 @@ "scripts": { "start": "webpack-dev-server", "build-app": "webpack", - "serve": "node ./node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js" + "serve": "node ./node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js" }, "keywords": [], "author": "", diff --git a/test/benchmarking-apps/aurelia2/package.json b/test/benchmarking-apps/aurelia2/package.json index a08ab9444d..d0231f4094 100644 --- a/test/benchmarking-apps/aurelia2/package.json +++ b/test/benchmarking-apps/aurelia2/package.json @@ -7,7 +7,7 @@ "scripts": { "start": "webpack-dev-server", "build-app": "webpack", - "serve": "node ../../../node_modules/@aurelia/http-server/dist/bundle/cli.js au.conf.js" + "serve": "node ../../../node_modules/@aurelia/http-server/dist/esm/cli.js au.conf.js" }, "keywords": [], "author": "", diff --git a/test/benchmarking-apps/runner/src/start-app-and-bench.ts b/test/benchmarking-apps/runner/src/start-app-and-bench.ts index f3b9a00744..b04c04de17 100644 --- a/test/benchmarking-apps/runner/src/start-app-and-bench.ts +++ b/test/benchmarking-apps/runner/src/start-app-and-bench.ts @@ -85,7 +85,7 @@ async function startApp(fxName: string, appPath: string, port: string) { const app = spawn( 'node', [ - '../../../packages/http-server/dist/bundle/cli.js', + '../../../packages/http-server/dist/esm/cli.js', '--root', join(appPath, 'dist'), '--port', diff --git a/test/karma-aurelia-preprocessor/index.js b/test/karma-aurelia-preprocessor/index.js index 34bedb2e26..554ac7b071 100644 --- a/test/karma-aurelia-preprocessor/index.js +++ b/test/karma-aurelia-preprocessor/index.js @@ -83,7 +83,7 @@ function createAureliaPreprocessor(karmaConfig, logger) { let newSpecifier = specifier; if (specifier.startsWith('@aurelia/')) { const packageName = specifier.slice(9 /* '@aurelia/'.length */); - const packageEntryFilePath = path.join(basePath, `base/packages/${packageName}/dist/${packageName === '__tests__' ? 'esm' : 'bundle'}/index.js`); + const packageEntryFilePath = path.join(basePath, `base/packages/${packageName}/dist/esm/index.js`); newSpecifier = path.relative(file.path, packageEntryFilePath).replace(/\\/g, '/'); } else if (specifier.startsWith('@babel/')) { const babelModulePath = specifier.slice(7 /* '@babel/runtime/'.length */);