Skip to content

Instantly share code, notes, and snippets.

@IWANABETHATGUY
Created September 21, 2023 06:41
Show Gist options
  • Save IWANABETHATGUY/b41d0f80a558580010276a44b310a473 to your computer and use it in GitHub Desktop.
Save IWANABETHATGUY/b41d0f80a558580010276a44b310a473 to your computer and use it in GitHub Desktop.
cjs-export-computed-property test case

source code

// index.js
export function test() {

}

webpack.config.js

const HtmlPlugin = require("html-webpack-plugin");

/**@type {import('webpack').Configuration} */
module.exports = {
	mode: "production",
	entry: { a: "./a/index.js" },
	resolve: {
		// Add `.ts` and `.tsx` as a resolvable extension.
		extensions: [".ts", ".tsx", ".js", ".mjs"],
		// Add support for TypeScripts fully qualified ESM imports.
		extensionAlias: {
			".js": [".js", ".ts"],
			".cjs": [".cjs", ".cts"],
			".mjs": [".mjs", ".mts"],
		},
	},
	target: ["web", "es5"],
	output: {
		publicPath: "/",
	},
	plugins: [
	],
	optimization: {
		innerGraph: false,
		usedExports:'global',
		minimize: false,
		mangleExports: false,
		concatenateModules: false,
		providedExports: true,
		sideEffects: true,
		moduleIds: "named",
    removeAvailableModules: false
	}

	devtool: false,
};

result

/******/ (function() { // webpackBootstrap
/******/ 	"use strict";
/******/ 	// The require scope
/******/ 	var __webpack_require__ = {};
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/define property getters */
/******/ 	!function() {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = function(exports, definition) {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	!function() {
/******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ 	}();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
/* unused harmony export test */
function test() {

}

/******/ })()
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment