Skip to content

Commit

Permalink
build(plugin-webpack): Build explicit cjs/esm modules
Browse files Browse the repository at this point in the history
  • Loading branch information
vio committed Aug 17, 2024
1 parent 727b59f commit 2c1de39
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 33 deletions.
57 changes: 56 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 16 additions & 11 deletions packages/plugin-webpack-filter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@
"name": "@bundle-stats/plugin-webpack-filter",
"version": "4.14.1",
"description": "BundleStats webpack filter plugin",
"main": "lib/index.js",
"module": "lib-esm/index.js",
"types": "types/index.d.ts",
"main": "lib/index.cjs",
"module": "lib-esm/index.mjs",
"types": "lib-esm/index.d.ts",
"sideEffects": false,
"exports": {
".": {
"import": "./lib-esm/index.mjs",
"require": "./lib/index.cjs",
"types": "./lib-esm/index.d.ts"
}
},
"engines": {
"node": ">= 14.0"
},
"directories": {
"lib": "lib"
"lib": "lib",
"lib-esm": "lib-esm"
},
"scripts": {
"build": "npm run clean && npm run build-lib && npm run build-esm",
"build-lib": "npm run clean-lib && tsc --rootDir ./src --project tsconfig.lib.json --outDir ./lib",
"build-esm": "npm run clean-esm && tsc --rootDir ./src --project tsconfig.esm.json --outDir ./lib-esm",
"clean": "npm run clean-lib && npm run clean-esm",
"clean-lib": "rimraf lib",
"clean-esm": "rimraf lib-esm types",
"build": "npm run clean && rollup -c rollup.config.mjs",
"clean": "rimraf lib lib-esm",
"lint": "eslint",
"test": "TZ=UTC jest src --maxWorkers=4"
},
Expand All @@ -38,14 +42,15 @@
},
"homepage": "https://github.com/relative-ci/bundle-stats/blob/master/packages/plugin-webpack-filter#readme",
"devDependencies": {
"@rollup/plugin-typescript": "11.1.6",
"@types/jest": "29.5.12",
"@types/webpack": "5.28.5",
"core-js": "3.38.0",
"jest": "29.7.0",
"jest-cli": "29.7.0",
"jest-date-mock": "1.0.10",
"regenerator-runtime": "0.14.1",
"rimraf": "6.0.1",
"rollup": "4.20.0",
"ts-jest": "29.2.4",
"typescript": "5.5.4"
},
Expand Down
25 changes: 25 additions & 0 deletions packages/plugin-webpack-filter/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineConfig } from 'rollup';
import typescript from '@rollup/plugin-typescript';

export default defineConfig([
{
input: './src/index.ts',
output: {
dir: 'lib-esm',
format: 'esm',
entryFileNames: '[name].mjs',
sourcemap: true,
},
plugins: [typescript({ declarationDir: 'lib-esm' })],
},
{
input: './src/index.ts',
output: {
dir: 'lib',
format: 'commonjs',
entryFileNames: '[name].cjs',
sourcemap: true,
},
plugins: [typescript({ declarationDir: 'lib' })],
},
]);
4 changes: 4 additions & 0 deletions packages/plugin-webpack-filter/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import filter from './index';

/* eslint-disable import/no-relative-packages */
// @ts-ignore
import webpackStats from '../../utils/__fixtures__/webpack-stats-1';
// @ts-ignore
import webpackStatsExtracted from '../../utils/__fixtures__/webpack-stats-1.extracted';
// @ts-ignore
import webpackStatsConcatenatedModules from '../../utils/__fixtures__/webpack-stats-3';
// @ts-ignore
import webpackStatsConcatenatedModulesExtracted from '../../utils/__fixtures__/webpack-stats-3.extracted';
/* eslint-enable import/no-relative-packages */

Expand Down
11 changes: 0 additions & 11 deletions packages/plugin-webpack-filter/tsconfig.esm.json

This file was deleted.

8 changes: 6 additions & 2 deletions packages/plugin-webpack-filter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"exclude": ["**/*.test.ts"]
"include": ["src"],
"exclude": ["node_modules", "src/**/*.test.ts"],
"compilerOptions": {
"declaration": true,
"moduleResolution": "node"
}
}
8 changes: 0 additions & 8 deletions packages/plugin-webpack-filter/tsconfig.lib.json

This file was deleted.

0 comments on commit 2c1de39

Please sign in to comment.