diff --git a/config/tsconfig.base.json b/config/tsconfig.base.json index 10e27a3f75..f1e6d61a4c 100644 --- a/config/tsconfig.base.json +++ b/config/tsconfig.base.json @@ -1,5 +1,5 @@ { - "version": "3.2.4", + "version": "3.5.3", "compilerOptions": { "allowSyntheticDefaultImports": true, "declaration": true, diff --git a/packages/core/package.json b/packages/core/package.json index 4af25e2b9e..4cba9a6f4a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -10,9 +10,9 @@ "unpkg": "dist/core.bundle.js", "sideEffects": [ "*.css", - "lib/esm/components/index.js", - "lib/esnext/components/index.js", - "lib/cjs/components/index.js" + "lib/esm/common/configureDom4.js", + "lib/esnext/common/configureDom4.js", + "lib/cjs/common/configureDom4.js" ], "bin": { "upgrade-blueprint-2.0.0-rename": "./scripts/upgrade-blueprint-2.0.0-rename.sh", diff --git a/packages/core/src/common/configureDom4.ts b/packages/core/src/common/configureDom4.ts new file mode 100644 index 0000000000..f8f6651951 --- /dev/null +++ b/packages/core/src/common/configureDom4.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2019 Palantir Technologies, Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +if (typeof require !== "undefined" && typeof window !== "undefined" && typeof document !== "undefined") { + // we're in browser + // tslint:disable-next-line:no-var-requires + require("dom4"); // only import actual dom4 if we're in the browser (not server-compatible) + // we'll still need dom4 types for the TypeScript to compile, these are included in package.json +} diff --git a/packages/core/src/common/utils/isDarkTheme.ts b/packages/core/src/common/utils/isDarkTheme.ts index c819c4fcd6..b4467c35ca 100644 --- a/packages/core/src/common/utils/isDarkTheme.ts +++ b/packages/core/src/common/utils/isDarkTheme.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import "../configureDom4"; + import { Classes } from "../"; export function isDarkTheme(element: Element | Text | null): boolean { diff --git a/packages/core/src/components/index.ts b/packages/core/src/components/index.ts index 1bbd4ff45a..d3b7d89207 100644 --- a/packages/core/src/components/index.ts +++ b/packages/core/src/components/index.ts @@ -14,13 +14,7 @@ * limitations under the License. */ -declare function require(moduleName: string): any; // declare node.js "require" so that we can conditionally import -if (typeof window !== "undefined" && typeof document !== "undefined") { - // we're in browser - // tslint:disable-next-line:no-var-requires - require("dom4"); // only import actual dom4 if we're in the browser (not server-compatible) - // we'll still need dom4 types for the TypeScript to compile, these are included in package.json -} +import "../common/configureDom4"; import * as contextMenu from "./context-menu/contextMenu"; export const ContextMenu = contextMenu;