From 9fd662fdce022f5a32d0ec79a97ad8846ed3ff26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 12 Jul 2022 13:07:03 +0200 Subject: [PATCH] [FIX] package.json: remove browser value As far as I can tell, the browser value overrides the main value in many cases. But then, we don't want to use the iife format, since it don't work well with bundlers. This commit fixes the issue by simply removing the key, so the main entry will be used instead. maybe fixes #1181 --- package.json | 1 - rollup.config.js | 24 ++++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index bd302fdd..34f25f4c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,6 @@ "version": "2.0.0-beta-14", "description": "Odoo Web Library (OWL)", "main": "dist/owl.cjs.js", - "browser": "dist/owl.iife.js", "module": "dist/owl.es.js", "types": "dist/types/owl.d.ts", "files": [ diff --git a/rollup.config.js b/rollup.config.js index 1372ffd8..54591f0a 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,6 +6,14 @@ import dts from "rollup-plugin-dts"; let input, output; +const IIFE_FILENAME = "dist/owl.iife.js"; +const CJS_FILENAME = "dist/owl.cjs.js"; +const ES_FILENAME = "dist/owl.es.js"; + +if (pkg.module !== ES_FILENAME || pkg.main !== CJS_FILENAME) { + throw new Error("package.json has been modified. Build script should be updated accordingly"); +} + const outro = ` __info__.version = '${pkg.version}'; __info__.date = '${new Date().toISOString()}'; @@ -23,19 +31,19 @@ switch (process.argv[4]) { case "runtime": input = "src/runtime/index.ts"; output = [ - getConfigForFormat('esm', addSuffix(pkg.module, 'runtime'), outro), - getConfigForFormat('cjs', addSuffix(pkg.main, 'runtime'), outro), - getConfigForFormat('iife', addSuffix(pkg.browser, 'runtime'), outro), - getConfigForFormat('iife', addSuffix(pkg.browser, 'runtime'), outro, true), + getConfigForFormat('esm', addSuffix(ES_FILENAME, 'runtime'), outro), + getConfigForFormat('cjs', addSuffix(CJS_FILENAME, 'runtime'), outro), + getConfigForFormat('iife', addSuffix(IIFE_FILENAME, 'runtime'), outro), + getConfigForFormat('iife', addSuffix(IIFE_FILENAME, 'runtime'), outro, true), ] break; default: input = "src/index.ts", output = [ - getConfigForFormat('esm', pkg.module, outro), - getConfigForFormat('cjs', pkg.main, outro), - getConfigForFormat('iife', pkg.browser, outro), - getConfigForFormat('iife', pkg.browser, outro, true), + getConfigForFormat('esm', ES_FILENAME, outro), + getConfigForFormat('cjs', CJS_FILENAME, outro), + getConfigForFormat('iife', IIFE_FILENAME, outro), + getConfigForFormat('iife', IIFE_FILENAME, outro, true), ] }