Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: bundle-stats/core #3456

Open
wants to merge 1 commit into
base: v5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"workspaces": [
"packages/cli",
"packages/cli-utils",
"packages/core",
"packages/gatsby-plugin",
"packages/html-templates",
"packages/next-plugin",
Expand Down
5 changes: 5 additions & 0 deletions packages/core/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
lib
lib-esm
types
!**/.*.js
7 changes: 7 additions & 0 deletions packages/core/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
rules: {
'import/no-cycle': ['warn', { maxDepth: 1 }],
'object-curly-newline': 'off',
'function-paren-newline': 'off',
},
};
12 changes: 12 additions & 0 deletions packages/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules/
.DS_Store
Thumbs.db
.idea/
.vscode/
*.sublime-project
*.sublime-workspace
*.log
yarn.lock
lib
lib-esm
types
10 changes: 10 additions & 0 deletions packages/core/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
**/__tests__
__fixtures__
.editorconfig
.eslintignore
.eslintrc.js
jsconfig.json
jest.config.js
jest.global.js
tsconfig.*
1 change: 1 addition & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @bundle-stats/core
5 changes: 5 additions & 0 deletions packages/core/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
preset: 'ts-jest/presets/js-with-ts',
testEnvironment: 'node',
testPathIgnorePatterns: ['/__fixtures__/', '/node_modules/', '/lib/', '/lib-esm/', '/types/'],
};
37 changes: 37 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@bundle-stats/core",
"version": "4.4.0",
"description": "BundleStats core functionality",
"main": "lib/index.js",
"module": "lib-esm/index.js",
"types": "types/index.d.ts",
"sideEffects": false,
"engines": {
"node": ">= 16.0"
},
"directories": {
"lib": "lib"
},
"scripts": {
"build": "npm run build-lib && npm run build-esm",
"build-lib": "rm -fr ./lib && npx tsc --rootDir ./src --project tsconfig.lib.json --outDir ./lib",
"build-esm": "rm -fr ./lib-esm && rm -fr ./types && npx tsc --rootDir ./src --project tsconfig.esm.json --outDir ./lib-esm",
"lint": "npx eslint . --ext .js,.ts --resolve-plugins-relative-to ../../",
"test": "jest"
},
"keywords": [],
"author": {
"name": "Viorel Cojocaru",
"email": "[email protected]",
"url": "https://beanon.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/relative-ci/bundle-stats.git"
},
"bugs": {
"url": "https://github.com/relative-ci/bundle-stats/issues"
},
"homepage": "https://github.com/relative-ci/bundle-stats/blob/master/packages/core#readme"
}
33 changes: 33 additions & 0 deletions packages/core/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import filter from './index';

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

describe('Webpack filter', () => {
test('should return empty meta', () => {
const actual = filter({
...webpackStats,
builtAt: undefined,
hash: undefined,
} as any);
expect({
...webpackStatsExtracted,
builtAt: undefined,
hash: undefined,
}).toEqual(actual);
});

test('should return meta', () => {
const actual = filter(webpackStats as any);
expect(actual).toEqual(webpackStatsExtracted);
});

test('should filter concatenated modules', () => {
const actual = filter(webpackStatsConcatenatedModules as any);
expect(actual).toEqual(webpackStatsConcatenatedModulesExtracted);
});
});
Empty file added packages/core/src/index.ts
Empty file.
11 changes: 11 additions & 0 deletions packages/core/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "ES2019",
"module": "ES6",
"declaration": true,
"declarationDir": "./types",
"noEmit": false
},
"exclude": ["**/*.test.ts"]
}
4 changes: 4 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"]
}
7 changes: 7 additions & 0 deletions packages/core/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false
},
"exclude": ["**/*.test.ts"]
}