diff --git a/webpack/webpack.config.base.ts b/webpack/webpack.config.base.ts index c75213d..f45ebb1 100644 --- a/webpack/webpack.config.base.ts +++ b/webpack/webpack.config.base.ts @@ -1,8 +1,9 @@ -// #region shared with https://github.com/paranext/paranext-multi-extension-template/blob/main/webpack/webpack.config.base.ts - import path from 'path'; import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'; import webpack from 'webpack'; +import { LIBRARY_TYPE } from './webpack.util'; + +// #region shared with https://github.com/paranext/paranext-multi-extension-template/blob/main/webpack/webpack.config.base.ts const isDev = process.env.NODE_ENV !== 'production'; const shouldGenerateSourceMaps = isDev || process.env.DEBUG_PROD; @@ -10,16 +11,6 @@ const shouldGenerateSourceMaps = isDev || process.env.DEBUG_PROD; /** The base directory from which webpack should operate (should be the root repo folder) */ export const rootDir = path.resolve(__dirname, '..'); -/** - * The module format of library we want webpack to use for externals and create for our extensions - * - * @see webpack.Configuration['externalsType'] for info about external import format - * @see webpack.LibraryOptions['type'] for info about library format - */ -// commonjs-static formats the code to export everything on module.exports. so it works -// well in cjs or esm https://webpack.js.org/configuration/output/#type-commonjs-static -export const LIBRARY_TYPE: NonNullable = 'commonjs-static'; - // Note: we do not want to do any chunking because neither webViews nor main can import dependencies // other than those listed in configBase.externals. Each webView must contain all its dependency // code, and main must contain all its dependency code. diff --git a/webpack/webpack.config.main.ts b/webpack/webpack.config.main.ts index 5a25bc6..ec85634 100644 --- a/webpack/webpack.config.main.ts +++ b/webpack/webpack.config.main.ts @@ -2,9 +2,9 @@ import webpack from 'webpack'; import path from 'path'; import merge from 'webpack-merge'; import CopyPlugin from 'copy-webpack-plugin'; -import configBase, { LIBRARY_TYPE, rootDir } from './webpack.config.base'; +import configBase, { rootDir } from './webpack.config.base'; import WebViewResolveWebpackPlugin from './web-view-resolve-webpack-plugin'; -import { outputFolder } from './webpack.util'; +import { LIBRARY_TYPE, outputFolder } from './webpack.util'; /** Webpack configuration for building main */ const configMain: webpack.Configuration = merge(configBase, { diff --git a/webpack/webpack.util.ts b/webpack/webpack.util.ts index cf465e3..ea78e4a 100644 --- a/webpack/webpack.util.ts +++ b/webpack/webpack.util.ts @@ -25,6 +25,16 @@ export const webViewTempDir = 'temp-build'; /** Folder containing the built extension files */ export const outputFolder = 'dist'; +/** + * The module format of library we want webpack to use for externals and create for our extensions + * + * @see webpack.Configuration['externalsType'] for info about external import format + * @see webpack.LibraryOptions['type'] for info about library format + */ +// commonjs-static formats the code to export everything on module.exports. so it works +// well in cjs or esm https://webpack.js.org/configuration/output/#type-commonjs-static +export const LIBRARY_TYPE: NonNullable = 'commonjs-static'; + /** Get a list of TypeScript WebView files to bundle. Path relative to project root */ function getWebViewTsxPaths() { return glob(webViewTsxGlob, { ignore: 'node_modules/**' });