Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"turbo": "^2.3.3",
"typescript": "~5.7.2",
"typescript-eslint": "^8.18.1",
"vue": "3.3.4",
"vue": "3.5.13",
"vue-tsc": "^2.1.10"
},
"resolutions": {
Expand Down
5 changes: 3 additions & 2 deletions packages/web-forms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"build:clean": "rimraf dist/ dist-demo/",
"build:demo": "vite build --mode demo --outDir dist-demo",
"build:js": "vite build",
"build:wc": "vite build --mode web-component --outDir dist-web-component",
"dev": "vite",
"dist-demo": "yarn build && yarn vite serve dist-demo --port 5174",
"test": "npm-run-all -nl test:*",
Expand Down Expand Up @@ -68,10 +69,10 @@
"vite-plugin-css-injected-by-js": "^3.5.2",
"vite-plugin-static-copy": "^2.2.0",
"vitest": "^2.1.8",
"vue": "3.3.4",
"vue": "3.5.13",
"vue-router": "^4.5.0"
},
"peerDependencies": {
"vue": "^3.3.4"
"vue": "^3.5.13"
}
}
11 changes: 11 additions & 0 deletions packages/web-forms/src/index.wc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineCustomElement } from 'vue';
import { OdkWebForm, webFormsPlugin } from '.';

const WebFormElement = defineCustomElement(OdkWebForm, {
configureApp(app) {
app.use(webFormsPlugin);
},
shadowRoot: false
});

customElements.define('odk-web-form', WebFormElement);
12 changes: 12 additions & 0 deletions packages/web-forms/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,26 @@ const copyConfigFile = viteStaticCopy({
export default defineConfig(({ mode }) => {
const isVueBundled = mode === 'demo';
const isDev = mode === 'development';
const isWebComponent = mode === 'web-component';

let lib: LibraryOptions | undefined;
let external: string[];
let globals: Record<string, string>;
let publicDir: string | false = "public";
const extraPlugins: PluginOption[] = [];

if (isVueBundled) {
external = [];
globals = {};
extraPlugins.push(copyConfigFile);
} else if (isWebComponent) {
lib = {
formats: ['es'],
entry: resolve(__dirname, 'src/index.wc.ts'),
name: 'OdkWebForms',
fileName: 'odk-web-form',
};
publicDir = false;
} else {
external = ['vue'];
globals = { vue: 'Vue' };
Expand All @@ -97,6 +107,7 @@ export default defineConfig(({ mode }) => {
return {
define: {
__WEB_FORMS_VERSION__: `"v${currentVersion}"`,
'process.env': {},
},
base: './',
plugins: [vue(), vueJsx(), cssInjectedByJsPlugin(), ...extraPlugins],
Expand Down Expand Up @@ -180,6 +191,7 @@ export default defineConfig(({ mode }) => {
optimizeDeps: {
force: true,
},
publicDir,
test: {
browser: {
enabled: BROWSER_ENABLED,
Expand Down
Loading