Skip to content

Commit

Permalink
Moved LIBRARY_TYPE to match multi template
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcouch-sil committed Oct 14, 2024
1 parent 94c18cb commit 43898cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
15 changes: 3 additions & 12 deletions webpack/webpack.config.base.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
// #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;

/** 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.<export_name> so it works
// well in cjs or esm https://webpack.js.org/configuration/output/#type-commonjs-static
export const LIBRARY_TYPE: NonNullable<webpack.Configuration['externalsType']> = '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.
Expand Down
4 changes: 2 additions & 2 deletions webpack/webpack.config.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
10 changes: 10 additions & 0 deletions webpack/webpack.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.<export_name> so it works
// well in cjs or esm https://webpack.js.org/configuration/output/#type-commonjs-static
export const LIBRARY_TYPE: NonNullable<webpack.Configuration['externalsType']> = 'commonjs-static';

/** Get a list of TypeScript WebView files to bundle. Path relative to project root */
function getWebViewTsxPaths() {
return glob(webViewTsxGlob, { ignore: 'node_modules/**' });
Expand Down

0 comments on commit 43898cb

Please sign in to comment.