Skip to content

Commit

Permalink
Merge pull request #1 from namecheap/feature/webpackv5
Browse files Browse the repository at this point in the history
feat: support webpack v5
  • Loading branch information
stas-nc authored Jan 24, 2025
2 parents 35fb1e8 + bf683b2 commit 98ab5af
Show file tree
Hide file tree
Showing 24 changed files with 12,325 additions and 11,939 deletions.
40 changes: 0 additions & 40 deletions .all-contributorsrc

This file was deleted.

4 changes: 0 additions & 4 deletions .autorc

This file was deleted.

129 changes: 0 additions & 129 deletions .circleci/config.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .circleci/semver-check.sh

This file was deleted.

27 changes: 0 additions & 27 deletions .eslintrc.json

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI

on:
push:
branches:
- master
tags-ignore:
- '**'
pull_request:
branches:
- '**'

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- if: github.event_name == 'pull_request'
name: Lint commit messages
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
- run: npm run lint
- run: npm run build
- run: npm run test
- run: npm run test:example
- if: matrix.node-version == '20.x'
uses: actions/upload-artifact@v4
with:
name: Code coverage
path: coverage/

publish:
name: 'Publish'
needs: build
runs-on: ubuntu-latest
environment: npm_publish
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- run: npm ci
- name: Publish new version
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
# run: npx semantic-release --dry-run --branches "$GITHUB_REF_NAME"
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit $1
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
npx lint-staged
npm run build
npm test
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 120,
"trailingComma": "all",
"singleQuote": true,
"tabWidth": 2,
"arrowParens": "avoid"
}
6 changes: 6 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('@commitlint/types').UserConfig}
*/
module.exports = {
extends: ['@commitlint/config-conventional'],
};
51 changes: 51 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import prettier from 'eslint-plugin-prettier';
import prettierConfig from 'eslint-config-prettier';
import noExplicitTypeExports from 'eslint-plugin-no-explicit-type-exports';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import js from '@eslint/js';
import xo from 'eslint-config-xo';

export default [
js.configs.recommended,
...xo,
prettierConfig,
{
files: ['**/*.ts'],
plugins: {
'@typescript-eslint': typescriptEslint,
prettier,
'no-explicit-type-exports': noExplicitTypeExports,
},

languageOptions: {
globals: {
...globals.node,
},

parser: tsParser,
ecmaVersion: 5,
sourceType: 'module',

parserOptions: {
project: './tsconfig.json',
},
},

settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},

rules: {
'no-explicit-type-exports/no-explicit-type-exports': 2,
'no-unused-vars': ['off'],
'no-undef': ['off'],
'no-unused-expressions': ['off'],
},
},
];
8 changes: 4 additions & 4 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const InjectPlugin = require('..').default;
const { WebpackInjectPlugin } = require('..');

module.exports = {
entry: './entry.js',
mode: 'development',
plugins: [
new InjectPlugin(() => `console.log('hello world');`),
new InjectPlugin(() => `console.log('second injected code');`)
]
new WebpackInjectPlugin(() => `console.log('hello world');`),
new WebpackInjectPlugin(() => `console.log('second injected code');`),
],
};
25 changes: 10 additions & 15 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
module.exports = {
moduleFileExtensions: ['ts', 'js'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest'
},
globals: {
'ts-jest': {
tsConfig: 'tsconfig.json'
}
},
collectCoverage: true,
testPathIgnorePatterns: ['node_modules', 'dist'],
coverageDirectory: './coverage',
coverageReporters: ['cobertura', 'html', 'lcov']
};
module.exports = {
moduleFileExtensions: ['ts', 'js'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
collectCoverage: true,
testPathIgnorePatterns: ['node_modules', 'dist'],
coverageDirectory: './coverage',
coverageReporters: ['cobertura', 'html', 'lcov'],
};
7 changes: 7 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @type {import('lint-staged').Config}
*/
module.exports = {
'*': 'prettier --ignore-unknown --write',
'*.ts': 'npm run lint -- --fix',
};
Loading

0 comments on commit 98ab5af

Please sign in to comment.