-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from OpenFn/tidy-project
Tidy project
- Loading branch information
Showing
24 changed files
with
272 additions
and
299 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@openfn/describe-package': patch | ||
--- | ||
|
||
Include worker bundle in package |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## Examples | ||
|
||
The example apps serve to illustrate how these packages can be used, and also | ||
for development, any changes detected in the dependencies will trigger a rebuild in the example. | ||
|
||
**ProjectSpace Flow** | ||
|
||
Uses packages/workflow-diagram | ||
|
||
From root: | ||
``` | ||
pnpm run -C examples/flow start | ||
``` | ||
|
||
**DTS Inspector** | ||
|
||
Uses packages/describe-package | ||
|
||
From root: | ||
``` | ||
pnpm run -C examples/describe-package start | ||
``` |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
examples/compiler-worker/CHANGELOG.md → examples/dts-inspector/CHANGELOG.md
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# compiler-worker | ||
# dts-inspector | ||
|
||
## 1.0.5 | ||
|
||
|
4 changes: 2 additions & 2 deletions
4
examples/compiler-worker/README.md → examples/dts-inspector/README.md
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
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
examples/compiler-worker/package.json → examples/dts-inspector/package.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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ import { createRoot } from "react-dom/client"; | |
|
||
import "./app.css"; | ||
import { StatusIcon, FuncIcon } from "./icons"; | ||
import { Pack, Project, describeDts } from "@openfn/compiler"; | ||
import { Pack, Project, describeDts } from "@openfn/describe-package"; | ||
|
||
const packageOrDts = /(?:package.json)|(?:\.d\.ts$)/i; | ||
const moduleOptions = ["@openfn/[email protected]"]; | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,93 @@ | ||
import { build } from 'esbuild'; | ||
import path from 'path'; | ||
import { readFile, rm } from 'fs/promises'; | ||
import { BuildOptions } from 'esbuild'; | ||
|
||
export default function rawPlugin() { | ||
return { | ||
name: 'raw', | ||
setup(build) { | ||
build.onResolve({ filter: /\?raw$/ }, (args) => { | ||
return { | ||
path: path.isAbsolute(args.path) | ||
? args.path | ||
: path.join(args.resolveDir, args.path), | ||
namespace: 'raw-loader', | ||
}; | ||
}); | ||
build.onLoad( | ||
{ filter: /\?raw$/, namespace: 'raw-loader' }, | ||
async (args) => { | ||
return { | ||
contents: await readFile(args.path.replace(/\?raw$/, '')), | ||
loader: 'text', | ||
}; | ||
} | ||
); | ||
}, | ||
}; | ||
} | ||
|
||
// esbuild watch in dev mode to rebuild out files | ||
const watchOptions = { | ||
onRebuild(error) { | ||
if (error) | ||
console.error('esbuild: Watch build failed:', error.getMessage()); | ||
else console.log('esbuild: Watch build succeeded'); | ||
}, | ||
}; | ||
|
||
let watch = process.argv[2] === 'watch' ? watchOptions : false; | ||
|
||
const commonBuildOptions: BuildOptions = { | ||
bundle: true, | ||
write: true, | ||
watch, | ||
format: 'esm', | ||
target: ['es2020'], | ||
outdir: './dist', | ||
external: ['fs', 'events', 'stream', 'path', 'util', 'constants', 'assert'], | ||
pure: ['console.log', 'console.time', 'console.timeEnd'], | ||
sourcemap: false, | ||
}; | ||
|
||
try { | ||
/** | ||
* WebWorker internals modules | ||
* This is the bundle that includes the Worker, Typescript and the interface | ||
* to query and interact with the Compiler. In order to provide a single file | ||
* for using the library we build just the worker, and later inject it into | ||
* the Worker entrypoint. | ||
*/ | ||
await build({ | ||
...commonBuildOptions, | ||
entryPoints: { | ||
'worker-internals': './src/worker/worker.ts', | ||
}, | ||
format: 'esm', | ||
minify: true, | ||
}); | ||
|
||
/** | ||
* WebWorker Entrypoint | ||
* This is the one that actually gets used in the browser, note the `rawPlugin` | ||
* which will load in the output of the `worker-internals` file as a string | ||
* into the entrypoint - allowing us to bundle both the worker code and the | ||
* entrypoint in the same file. | ||
*/ | ||
await build({ | ||
...commonBuildOptions, | ||
entryPoints: { | ||
worker: './src/worker/index.ts', | ||
}, | ||
format: 'esm', | ||
minify: false, | ||
plugins: [rawPlugin()], | ||
}); | ||
|
||
// Cleanup worker-internals since they are bundled into the worker. | ||
await rm('./dist/worker-internals.js'); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.