From 172423ee027e7a0accb463b297ba741b276400f0 Mon Sep 17 00:00:00 2001 From: Valentin Serra Date: Mon, 6 May 2024 09:13:43 +0200 Subject: [PATCH] feat: boostrap `viewer-render` project Related to https://github.com/bpmn-io/form-js/issues/1166 --- .gitignore | 1 + package-lock.json | 12 +++++++ .../RenderPlayground.jsx | 8 +++++ packages/form-js-viewer-render/index.html | 18 ++++++++++ packages/form-js-viewer-render/jsconfig.json | 22 ++++++++++++ packages/form-js-viewer-render/package.json | 35 +++++++++++++++++++ packages/form-js-viewer-render/src/index.js | 5 +++ .../form-js-viewer-render/src/jsconfig.json | 6 ++++ packages/form-js-viewer-render/test/.eslintrc | 9 +++++ .../form-js-viewer-render/test/index.spec.js | 5 +++ .../form-js-viewer-render/test/jsconfig.json | 11 ++++++ packages/form-js-viewer-render/vite.config.js | 23 ++++++++++++ 12 files changed, 155 insertions(+) create mode 100644 packages/form-js-viewer-render/RenderPlayground.jsx create mode 100644 packages/form-js-viewer-render/index.html create mode 100644 packages/form-js-viewer-render/jsconfig.json create mode 100644 packages/form-js-viewer-render/package.json create mode 100644 packages/form-js-viewer-render/src/index.js create mode 100644 packages/form-js-viewer-render/src/jsconfig.json create mode 100644 packages/form-js-viewer-render/test/.eslintrc create mode 100644 packages/form-js-viewer-render/test/index.spec.js create mode 100644 packages/form-js-viewer-render/test/jsconfig.json create mode 100644 packages/form-js-viewer-render/vite.config.js diff --git a/.gitignore b/.gitignore index 83ef9a4a2..3b10ae016 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules test-results/ playwright-report/ playwright/.cache/ +lerna-debug.log \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a61067bde..97b40d1c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2147,6 +2147,10 @@ "resolved": "packages/form-js-viewer-core", "link": true }, + "node_modules/@bpmn-io/form-js-viewer-render": { + "resolved": "packages/form-js-viewer-render", + "link": true + }, "node_modules/@bpmn-io/form-json-schema": { "resolved": "packages/form-json-schema", "link": true @@ -21670,6 +21674,11 @@ "version": "1.8.6", "license": "SEE LICENSE IN LICENSE" }, + "packages/form-js-viewer-render": { + "name": "@bpmn-io/form-js-viewer-render", + "version": "1.8.6", + "license": "SEE LICENSE IN LICENSE" + }, "packages/form-js-viewer/node_modules/big.js": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-6.2.2.tgz", @@ -23193,6 +23202,9 @@ "@bpmn-io/form-js-viewer-core": { "version": "file:packages/form-js-viewer-core" }, + "@bpmn-io/form-js-viewer-render": { + "version": "file:packages/form-js-viewer-render" + }, "@bpmn-io/form-json-schema": { "version": "file:packages/form-json-schema" }, diff --git a/packages/form-js-viewer-render/RenderPlayground.jsx b/packages/form-js-viewer-render/RenderPlayground.jsx new file mode 100644 index 000000000..4e97dd3f0 --- /dev/null +++ b/packages/form-js-viewer-render/RenderPlayground.jsx @@ -0,0 +1,8 @@ +import { foo } from './src/index.js'; +import { Fragment } from 'preact'; + +const RenderPlayground = () => { + return {foo()}; +}; + +export { RenderPlayground }; diff --git a/packages/form-js-viewer-render/index.html b/packages/form-js-viewer-render/index.html new file mode 100644 index 000000000..6378f055f --- /dev/null +++ b/packages/form-js-viewer-render/index.html @@ -0,0 +1,18 @@ + + + + + + + + @bpmn-io/form-js-viewer-render + + + + + + diff --git a/packages/form-js-viewer-render/jsconfig.json b/packages/form-js-viewer-render/jsconfig.json new file mode 100644 index 000000000..55d5e3f2b --- /dev/null +++ b/packages/form-js-viewer-render/jsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "ESNext", + "moduleResolution": "Bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "declaration": true, + "useUnknownInCatchVariables": true, + "paths": { + "@/*": ["./src/*"] + } + }, + "include": ["src"], + "exclude": ["node_modules"] +} diff --git a/packages/form-js-viewer-render/package.json b/packages/form-js-viewer-render/package.json new file mode 100644 index 000000000..242c72044 --- /dev/null +++ b/packages/form-js-viewer-render/package.json @@ -0,0 +1,35 @@ +{ + "name": "@bpmn-io/form-js-viewer-render", + "version": "1.8.6", + "description": "Render form state - powered by bpmn.io", + "type": "module", + "publishConfig": { + "access": "public" + }, + "main": "dist/index.cjs", + "module": "dist/index.js", + "types": "dist/types/index.d.ts", + "scripts": { + "all": "run-s test build", + "build": "run-p bundle generate-types", + "bundle": "vite build", + "dev": "vite", + "generate-types": "tsc --allowJs --skipLibCheck --declaration --emitDeclarationOnly --outDir dist/types src/index.js && copyfiles --flat src/*.d.ts dist/types", + "test": "vitest", + "prepublishOnly": "npm run build" + }, + "license": "SEE LICENSE IN LICENSE", + "repository": { + "type": "git", + "url": "git+https://github.com/bpmn-io/form-js.git", + "directory": "packages/form-js-viewer-render" + }, + "author": { + "name": "bpmn.io contributors", + "url": "https://github.com/bpmn-io" + }, + "sideEffects": false, + "files": [ + "dist" + ] +} diff --git a/packages/form-js-viewer-render/src/index.js b/packages/form-js-viewer-render/src/index.js new file mode 100644 index 000000000..b3f624ff3 --- /dev/null +++ b/packages/form-js-viewer-render/src/index.js @@ -0,0 +1,5 @@ +function foo() { + return 'foo'; +} + +export { foo }; diff --git a/packages/form-js-viewer-render/src/jsconfig.json b/packages/form-js-viewer-render/src/jsconfig.json new file mode 100644 index 000000000..168492a4c --- /dev/null +++ b/packages/form-js-viewer-render/src/jsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "../jsconfig.json", + "compilerOptions": { + "lib": ["ES2020", "DOM", "DOM.Iterable"] + } +} diff --git a/packages/form-js-viewer-render/test/.eslintrc b/packages/form-js-viewer-render/test/.eslintrc new file mode 100644 index 000000000..46ddfd457 --- /dev/null +++ b/packages/form-js-viewer-render/test/.eslintrc @@ -0,0 +1,9 @@ +{ + "extends": [ + "plugin:vitest-globals/recommended", + "plugin:prettier/recommended" + ], + "env": { + "vitest-globals/env": true + } +} diff --git a/packages/form-js-viewer-render/test/index.spec.js b/packages/form-js-viewer-render/test/index.spec.js new file mode 100644 index 000000000..24f150551 --- /dev/null +++ b/packages/form-js-viewer-render/test/index.spec.js @@ -0,0 +1,5 @@ +import { foo } from '@/index.js'; + +it('should pass a test', () => { + expect(foo()).toBe('foo'); +}); diff --git a/packages/form-js-viewer-render/test/jsconfig.json b/packages/form-js-viewer-render/test/jsconfig.json new file mode 100644 index 000000000..41402e905 --- /dev/null +++ b/packages/form-js-viewer-render/test/jsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../jsconfig.json", + "compilerOptions": { + "lib": ["ES2020"], + "types": ["@types/node", "vitest/globals"], + "esModuleInterop": true, + "declaration": false, + "resolveJsonModule": true + }, + "include": ["**/*.spec.js"] +} diff --git a/packages/form-js-viewer-render/vite.config.js b/packages/form-js-viewer-render/vite.config.js new file mode 100644 index 000000000..35f7197c3 --- /dev/null +++ b/packages/form-js-viewer-render/vite.config.js @@ -0,0 +1,23 @@ +import { resolve } from 'path'; +import { defineConfig } from 'vite'; +import preact from '@preact/preset-vite'; + +export default defineConfig({ + plugins: [preact()], + build: { + lib: { + entry: resolve(__dirname, 'src/index.js'), + fileName: 'index', + formats: ['es', 'cjs'], + }, + }, + resolve: { + alias: { + '@': resolve(__dirname, 'src'), + }, + }, + test: { + globals: true, + files: ['test/**/*.spec.js'], + }, +});