-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build process rewrite #134
Comments
Note re build topologyLernaI tried using npmI looked at yarnI tried switching to yarn and using the yarn workspaces-tools foreach but I only just realized that requires yarn v2 (i.e. "berry"). Trying yarn v2 just seemed to error on install:
Had it worked, then something like rushI'd never heard of this, but it has a number of smells considering the simple use-case we have, including the complex config. It seems to be overkill here. pnpmThis seems to lack the basic ability to call an arbitrary command in any given directory. Workspace-toolsI wonder if it's possible to directly use https://github.com/kenotron/workspace-tools hand-rollingAll of the above leads me to believe that we quite possibly want to go back to hand-rolling the dependency chain detection. Which is somewhat madness, if you ask me. |
Makefile metaHaving tried all the above, I'm going to look at building a It'll go something like this:
The dependencies will be targets that look something like this: packages/observable: packages/observable/dist/index.js packages/utils
packages/observable/dist/index.js:
cd packages/observable; $(MAKE)
packages/utils: packages/utils/dist/index.js
packages/utils/dist/index.js:
cd packages/observable; $(MAKE) We can generate the dependency list by parsing Build Dependency ChainIn Example: @tko/observable: @tko/utils However those dependencies won't know how or when to build, so we have to give file-system based dependencies e.g. on their @tko/observable: @tko/utils ../observable/dist/index.js
../observable/dist/index.js:
cd ../observable; $(MAKE) The problem here is that this is a circular loop: in the
The issue is that including |
I tried a DIY like this, but I think the solution might be to change #!/usr/bin/env node
//
// Generate deps.mk, so we've a proper
// topological sort of the dependencies.
//
// See: https://github.com/knockout/tko/issues/134
//
// This will eventully be replaceable by something like:
//
// yarn workspaces foreach
//
const path = require('path')
const fs = require('fs')
const packagesPath = path.join(__dirname, '..', 'packages')
const buf = [`# Auto-generated by create-deps
# Last generated: ${new Date().toISOString()}
`]
const include = pkgPath => {
const modulesPath = path.join(__dirname, '..', pkgPath)
const modules = fs.readdirSync(modulesPath)
const parse = module => JSON.parse(fs.readFileSync(
path.join(modulesPath, module, 'package.json')))
for (const pkg of modules) {
const package = parse(pkg)
const deps = Object.keys(package.dependencies || [])
.filter(d => d.includes('@tko'))
.map(d => `${d.replace(`@tko`, packagesPath)}/dist/index.js`)
.join(' ')
buf.push(`
// ${pkgPath}/${pkg} => ${package.name}
${package.name}:
../${pkg}/dist/index.js: ${package.name}/commonjs
\tcd ../${pkg}; $(MAKE)
${package.name}/commonjs: ${deps}
`)
}
}
include('packages')
include('builds')
console.log(buf.join('')) But this is rather fickle and the next dev to come along (quite possibly me) will be head-scratching for a while with this. |
Lerna with
|
✅ Unlinked packagesIt looks like the issue was with the
|
TestingNow that I'm through the build process, I'm trying testing. The CircleCI + SauceLabs config was antiquated and seemed to time out. I looked at a few options:
Since we've Mocha and Jasmine (an ancient version) tests we're somewhat hamstrung. Eventually I've considered moving everything to Jest with e.g. jest-codemods, but that's a separate effort. CircleCICircleCI seems to work ok, but it's an extra external dependency, so I wanted to try Github Actions to remove that support overhead. If more users start working on this, we can manage their respective access with Github users. Github Actions / SauceLabsThe Github Actions seem to work fine, though it took an effort to get them up-and-running with SauceLabs. We still get a timeout disconnect. I've temporarily disabled SauceLabs to try and run things locally in e.g. Electron, figuring that would be easier to set up. Github Actions / ElectronAfter some effort figuring out how to get headless Electron working, it seems that there's an error that occurs for no apparent reason in the headless setup but that does not occur when run locally, e.g.:
If I were to speculate I'd say that the test was depending on some timing that differs when run in headless Electron e.g. perhaps |
Given the difficulty I'm having with CI I'm going to just turn it off right now and re-evaluate the thing with a bit more dignity i.e. where it's not blocking a rewrite of the build process. |
The Electron issue may be this: electron/electron#9567. |
Background
Flowing from #130 and started implementing in #111, I am revisiting the build process. The last time we looked at this the build process was very challenging for a few reasons:
Since that last go-round, the ecosystem has changed and stabilized. ESM is now a relatively sure-thing in modern browsers and all recent build tools, and there are alternative build tools. As well, how npm, node, and build tools export packages has increased and become more stable/standardized.
We also have Deno in the landscape, to think about.
Objectives
packages/
frombuilds/
browser.min
(ES6)Technical Design
I've landed on replacing rollup with esbuild because it simplifies the build process substantially.
I tried replacing learn with Makefiles but the interdependencies were too complex, and learn works quite well for task delegation.
The test process requires switching to use a karma-esbuild, which seems to work quite well. There's some config overlap in what's passed to esbuild on the command line for building and what's in the
karma.conf
.The build process is somewhat fickle, so I'm adding tests to
build/reference/spec
that verify that the various processes export/import TKO as anticipated.Alternatives considered
rollup
, but the simplicity and speed of esbuild is compelling, and we are looking to using esbuild in a browser.The text was updated successfully, but these errors were encountered: