diff --git a/.editorconfig b/.editorconfig index 012966bd94e..2bd8cf9e86d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,21 +2,13 @@ root = true [*] indent_style = tab -indent_size = 4 +indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -max_line_length = 233 - -[*.json] -indent_style = space -indent_size = 2 - -[*.yml] -indent_style = space -indent_size = 2 +max_line_length = 80 -[*.yaml] +[*.{yml,yaml,json}] indent_style = space indent_size = 2 diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000000..7810041dfd8 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,27 @@ +# Ignore node_modules +node_modules + +# Ignore some folders +benchmark +coverage + +# Ignore not supported files +!.*.js +.eslintrc.js +*.d.ts + +# Ignore precompiled schemas +schemas/**/*.check.js + +# Ignore some test files +test/* +!test/*Cases +!test/helpers +!test/*.js +test/*Cases/**/*.js +!test/*Cases/**/webpack.config.js + +# Ignore some examples files +examples/**/*.js +!examples/*/webpack.config.js + diff --git a/.eslintrc.js b/.eslintrc.js index 291a4e25598..09a61797b11 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,69 +1,104 @@ module.exports = { - "root": true, - "plugins": ["node"], - "extends": ["eslint:recommended", "plugin:node/recommended"], - "env": { - "node": true, - "es6": true, + root: true, + plugins: ["prettier", "node", "jest", "jsdoc"], + extends: [ + "eslint:recommended", + "plugin:node/recommended", + "plugin:prettier/recommended" + ], + env: { + node: true, + es6: true }, - "parserOptions": { "ecmaVersion": 2017 }, - "rules": { - "quotes": ["error", "double"], - "no-undef": "error", - "no-extra-semi": "error", - "semi": "error", + parserOptions: { + ecmaVersion: 2018 + }, + rules: { + "prettier/prettier": "error", "no-template-curly-in-string": "error", "no-caller": "error", - "yoda": "error", - "eqeqeq": "error", - "global-require": "off", - "brace-style": "error", + "no-control-regex": "off", + yoda: "error", + eqeqeq: "error", "eol-last": "error", - "indent": ["error", "tab", { "SwitchCase": 1 }], "no-extra-bind": "warn", - "no-empty": "off", - "no-multiple-empty-lines": "error", - "no-multi-spaces": "error", "no-process-exit": "warn", - "space-in-parens": "error", - "no-trailing-spaces": "error", "no-use-before-define": "off", - "no-unused-vars": ["error", { "args": "none" }], - "key-spacing": "error", - "space-infix-ops": "error", - "no-unsafe-negation": "error", - "no-loop-func": "warn", - "space-before-function-paren": ["error", "never"], - "space-before-blocks": "error", - "object-curly-spacing": ["error", "always"], - "keyword-spacing": ["error", { - "after": false, - "overrides": { - "const": { "after": true }, - "try": { "after": true }, - "else": { "after": true }, - "throw": { "after": true }, - "case": { "after": true }, - "return": { "after": true }, - "finally": { "after": true }, - "do": { "after": true } - } - }], - "no-console": "off", - "valid-jsdoc": "error", - "node/no-unsupported-features": ["error", { version: 4 }], - "node/no-deprecated-api": "error", - "node/no-missing-import": "error", - "node/no-missing-require": [ + "no-unused-vars": ["error", { args: "none", ignoreRestSiblings: true }], + "no-loop-func": "off", + "node/no-missing-require": ["error", { allowModules: ["webpack"] }], + "jsdoc/check-indentation": "error", + "jsdoc/check-param-names": "error", + "jsdoc/check-property-names": "error", + "jsdoc/check-tag-names": "error", + "jsdoc/require-hyphen-before-param-description": ["error", "never"], + "jsdoc/require-param-description": "error", + "jsdoc/require-param-name": "error", + "jsdoc/require-param-type": "error", + "jsdoc/require-param": "error", + "jsdoc/require-property": "error", + "jsdoc/require-property-name": "error", + "jsdoc/require-property-type": "error", + "jsdoc/require-returns-description": "error", + "jsdoc/require-returns-type": "error", + "jsdoc/require-returns": "error", + // Disallow @ts-ignore directive. Use @ts-expect-error instead + "no-warning-comments": [ "error", - { - "allowModules": [ - "webpack" - ] + { terms: ["@ts-ignore"], location: "start" } + ] + }, + settings: { + jsdoc: { + mode: "typescript", + // supported tags https://github.com/microsoft/TypeScript-wiki/blob/master/JSDoc-support-in-JavaScript.md + tagNamePreference: { + ...["implements", "const", "memberof", "readonly", "yields"].reduce( + (acc, tag) => { + acc[tag] = { + message: `@${tag} currently not supported in TypeScript` + }; + return acc; + }, + {} + ), + extends: "extends", + return: "returns", + constructor: "constructor", + prop: "property", + arg: "param", + augments: "extends", + description: false, + desc: false, + inheritdoc: false, + class: "constructor" + }, + overrideReplacesDocs: false + } + }, + overrides: [ + { + files: ["lib/**/*.runtime.js", "hot/*.js"], + env: { + es6: false, + browser: true + }, + globals: { + Promise: false + }, + parserOptions: { + ecmaVersion: 5 + } + }, + { + files: ["test/**/*.js"], + env: { + "jest/globals": true + }, + globals: { + nsObj: false, + jasmine: false } - ], - "node/no-unpublished-bin": "error", - "node/no-unpublished-require": "error", - "node/process-exit-as-throw": "error" - } + } + ] }; diff --git a/.gitattributes b/.gitattributes index ac579eb7bc0..4a65e411fbd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,7 @@ * text=auto -test/statsCases/* eol=lf +test/statsCases/** eol=lf examples/* eol=lf -bin/* eol=lf \ No newline at end of file +bin/* eol=lf +*.svg eol=lf +*.css eol=lf +**/*webpack.lock.data/** -text diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000000..5e7c7b6d7a6 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +open_collective: webpack diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 98922e445b6..ba313faa478 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -12,11 +12,11 @@ **If the current behavior is a bug, please provide the steps to reproduce.** - + **What is the expected behavior?** **If this is a feature request, what is motivation or use case for changing the behavior?** -**Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.** +**Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.** diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md new file mode 100644 index 00000000000..437637672bb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -0,0 +1,39 @@ +--- +name: Bug report +about: Create a report to help us improve +--- + + + + +# Bug report + + + + + + +**What is the current behavior?** + + +**If the current behavior is a bug, please provide the steps to reproduce.** + + + + + + + + + +**What is the expected behavior?** + + + + + +**Other relevant information:** +webpack version: +Node.js version: +Operating System: +Additional tools: diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md new file mode 100644 index 00000000000..ff728e6db23 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -0,0 +1,27 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + + + +## Feature request + + + + + + + +**What is the expected behavior?** + + +**What is motivation or use case for adding/changing the behavior?** + + +**How should this be implemented in your opinion?** + + +**Are you willing to work on this yourself?** +yes diff --git a/.github/ISSUE_TEMPLATE/Other.md b/.github/ISSUE_TEMPLATE/Other.md new file mode 100644 index 00000000000..033e88fcad4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Other.md @@ -0,0 +1,9 @@ +--- +name: Other +about: Something else + +--- + + + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 7af602ab91a..8967c8f0169 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,9 @@ + + + + + **What kind of change does this PR introduce?** @@ -8,17 +13,11 @@ -**If relevant, link to documentation update:** - - - -**Summary** - - - - **Does this PR introduce a breaking change?** -**Other information** +**What needs to be documented once your changes are merged?** + + + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000000..097b6c90844 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: +- package-ecosystem: npm + directory: "/" + schedule: + interval: daily + time: "04:00" + timezone: Europe/Berlin + open-pull-requests-limit: 20 + labels: + - dependencies + versioning-strategy: widen diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000000..11a4dbe2a81 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,114 @@ +name: Test + +# cspell:word Ignus +# cspell:word eslintcache + +on: + push: + branches: + - main + - dev-1 + pull_request: + branches: + - main + - dev-1 + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 17.x + cache: "yarn" + - run: yarn --frozen-lockfile + - uses: actions/cache@v1 + with: + path: .eslintcache + key: lint-${{ env.GITHUB_SHA }} + restore-keys: lint- + - run: yarn lint + basic: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 17.x + cache: "yarn" + - run: yarn --frozen-lockfile + - run: yarn link --frozen-lockfile || true + - run: yarn link webpack --frozen-lockfile + - run: yarn test:basic --ci + - uses: codecov/codecov-action@v3 + with: + flags: basic + functionalities: gcov + unit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 17.x + cache: "yarn" + - run: yarn --frozen-lockfile + - run: yarn link --frozen-lockfile || true + - run: yarn link webpack --frozen-lockfile + - uses: actions/cache@v1 + with: + path: .jest-cache + key: jest-unit-${{ env.GITHUB_SHA }} + restore-keys: jest-unit- + - run: yarn cover:unit --ci --cacheDirectory .jest-cache + - uses: codecov/codecov-action@v3 + with: + flags: unit + functionalities: gcov + integration: + needs: basic + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + node-version: [10.x, 17.x] + part: [a, b] + include: + - os: ubuntu-latest + node-version: 16.x + part: a + - os: ubuntu-latest + node-version: 14.x + part: a + - os: ubuntu-latest + node-version: 12.x + part: a + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "yarn" + - run: yarn --frozen-lockfile + - run: yarn link --frozen-lockfile || true + - run: yarn link webpack --frozen-lockfile + - uses: actions/cache@v2 + with: + path: .jest-cache + key: jest-integration-${{ env.GITHUB_SHA }} + restore-keys: jest-integration- + - run: yarn cover:integration:${{ matrix.part }} --ci --cacheDirectory .jest-cache || yarn cover:integration:${{ matrix.part }} --ci --cacheDirectory .jest-cache -f + - run: yarn cover:merge + - uses: codecov/codecov-action@v3 + with: + flags: integration + functionalities: gcov diff --git a/.gitignore b/.gitignore index 84bc35a3aba..ed9bd295d03 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,22 @@ /node_modules /test/js /test/browsertest/js -/test/fixtures/temp-cache-fixture +/test/fixtures/temp-* +/test/temp +/test/ChangesAndRemovals +/test/**/dev-defaults.webpack.lock /benchmark/js /benchmark/fixtures -/examples/*/js +/examples/**/dist +/assembly/**/*.wat +/assembly/**/*.wasm /coverage +/.nyc_output +/.jest-cache .DS_Store *.log .idea .vscode +.cache +.eslintcache +package-lock.json diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 00000000000..31354ec1389 --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000000..d37daa075e2 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx --no-install lint-staged diff --git a/.istanbul.yml b/.istanbul.yml new file mode 100644 index 00000000000..380ddeb6d88 --- /dev/null +++ b/.istanbul.yml @@ -0,0 +1,4 @@ +instrumentation: + excludes: + - "**/*.runtime.js" + - ".github/*" diff --git a/.jsbeautifyrc b/.jsbeautifyrc deleted file mode 100644 index 79b04984674..00000000000 --- a/.jsbeautifyrc +++ /dev/null @@ -1,25 +0,0 @@ -{ - "js": { - "allowed_file_extensions": ["js", "json", "jshintrc", "jsbeautifyrc"], - "brace_style": "collapse", - "break_chained_methods": false, - "e4x": true, - "eval_code": false, - "end_with_newline": true, - "indent_char": "\t", - "indent_level": 0, - "indent_size": 1, - "indent_with_tabs": true, - "jslint_happy": false, - "jslint_happy_align_switch_case": true, - "space_after_anon_function": false, - "keep_array_indentation": false, - "keep_function_indentation": false, - "max_preserve_newlines": 2, - "preserve_newlines": true, - "space_before_conditional": false, - "space_in_paren": false, - "unescape_strings": false, - "wrap_line_length": 0 - } -} \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000000..9cf9495031e --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000000..bf425289bd9 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,14 @@ +package.json + +# Ignore test fixtures +test/*.* +!test/*.js +!test/**/webpack.config.js +!test/**/deprecations.js + +# Ignore example fixtures +examples/*.* +!examples/**/webpack.config.js + +# Ignore generated files +*.check.js diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 00000000000..2ddbbf13d25 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,22 @@ +module.exports = { + printWidth: 80, + useTabs: true, + tabWidth: 2, + trailingComma: "none", + arrowParens: "avoid", + overrides: [ + { + files: "*.json", + options: { + parser: "json", + useTabs: false + } + }, + { + files: "*.ts", + options: { + parser: "typescript" + } + } + ] +}; diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 90e4f1ef5be..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,46 +0,0 @@ -sudo: false -language: node_js - -branches: - only: - - master - -cache: - directories: - - $HOME/.npm - - $HOME/.yarn-cache - -matrix: - include: - - os: linux - node_js: "7" - env: NO_WATCH_TESTS=1 JOB_PART=lint - - os: linux - node_js: "7" - env: NO_WATCH_TESTS=1 JOB_PART=test - - os: linux - node_js: "6" - env: NO_WATCH_TESTS=1 JOB_PART=test - - os: linux - node_js: "4.3" - env: NO_WATCH_TESTS=1 JOB_PART=test - - os: osx - node_js: "7" - env: NO_WATCH_TESTS=1 JOB_PART=test - allow_failures: - - os: osx - fast_finish: true - -before_script: - - bash ./ci/travis-install.sh - -script: npm run travis:$JOB_PART - -after_success: - - cat ./coverage/lcov.info | node_modules/.bin/coveralls --verbose - - cat ./coverage/coverage.json | node_modules/codecov.io/bin/codecov.io.js - - rm -rf ./coverage - -notifications: - slack: - secure: JduSdKWwbnLCwo7Z4E59SGE+Uw832UwnXzQiKEpg1BV45MYDPRiGltly1tRHmPh9OGjvGx3XSkC2tNGOBLtL4UL2SCkf012x0t7jDutKRfcv/njynl8jk8l+UhPmaWiHXDQAgGiiKdL4RfzPLW3HeVHCOWm0LKMzcarTa8tw+rE= diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..4faf227c455 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1 @@ +[Code of Conduct](https://github.com/openjs-foundation/code-and-learn/blob/master/CODE_OF_CONDUCT.md) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e5279ebcecd..146a567a0c0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,38 +7,31 @@ work is not in vain. ## Issues -Most of the time, if webpack is not working correctly for you it is a simple configuration issue. +Most of the time, if webpack is not working correctly for you, it is a simple configuration issue. If you are still having difficulty after looking over your configuration carefully, please post -a question to [StackOverflow with the webpack tag](http://stackoverflow.com/tags/webpack). Questions -that include your webpack.config.js and relevant files are more likely to receive responses. +a question to [StackOverflow with the webpack tag](https://stackoverflow.com/tags/webpack). Questions +that include your webpack.config.js, relevant files, and the full error message are more likely to receive responses. -**If you have discovered a bug or have a feature suggestion, feel free to create an issue on Github.** +**If you have discovered a bug or have a feature suggestion, please [create an issue on GitHub](https://github.com/webpack/webpack/issues/new).** -## Contributing to the webpack ecosystem +Do you want to fix an issue? Look at the issues with a tag of [X5: work required (PR / Help Wanted)](https://github.com/webpack/webpack/labels/X5%3A%20work%20required%20%28PR%20%2F%20Help%20Wanted%29). Each issue should be tagged with a difficulty tag - -If you have created your own loader/plugin please include it on the relevant -documentation pages: +- D0: My First Commit (Contribution Difficulty) +- D1: Easy (Contribution Difficulty) +- D2: Medium (Contribution Difficulty) +- D3: Hard (Contribution Difficulty) -[List of loaders](https://webpack.js.org/loaders/) or [awesome-webpack](https://github.com/webpack-contrib/awesome-webpack#loaders) -[List of plugins](https://webpack.js.org/plugins) or [awesome-webpack](https://github.com/webpack-contrib/awesome-webpack#webpack-plugins) +## Contributing to the webpack ecosystem -## Setup +If you have created your own loader/plugin please include it on the relevant documentation pages: -```bash -git clone https://github.com/webpack/webpack.git -cd webpack -npm install -g yarn -yarn install -yarn link -yarn link webpack -``` +- [List of loaders](https://webpack.js.org/loaders/) or [awesome-webpack](https://github.com/webpack-contrib/awesome-webpack#loaders) +- [List of plugins](https://webpack.js.org/plugins) or [awesome-webpack](https://github.com/webpack-contrib/awesome-webpack#webpack-plugins) -To run the entire test suite use: +## Setup -```bash -yarn test -``` +[Setup your local webpack repository](_SETUP.md) ## Submitting Changes @@ -46,14 +39,30 @@ After getting some feedback, push to your fork and submit a pull request. We may suggest some changes or improvements or alternatives, but for small changes your pull request should be accepted quickly. -Some things that will increase the chance that your pull request is accepted: +Something that will increase the chance that your pull request is accepted: -* [Write tests](./test/README.md) -* Follow the existing coding style -* Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) +- [Write tests](./test/README.md) +- Follow the existing coding style +- Write a [good commit message](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) +- For a major fix/feature make sure your PR has an issue and if it doesn't, please create one. This would help discussion with the community, and polishing ideas in case of a new feature. +- Make sure your PR's description contains GitHub's special keyword references that automatically close the related issue when the PR is merged. ([More info](https://github.com/blog/1506-closing-issues-via-pull-requests)) +- When you have a lot of commits in your PR, it's good practice to squash all your commits in one single commit. ([Learn how to squash here](https://davidwalsh.name/squash-commits-git)) ## Documentation webpack is insanely feature rich and documentation is a huge time sink. We greatly appreciate any time spent fixing typos or clarifying sections in the -documentation. +documentation. [See a list of issues with the documentation tag](https://github.com/webpack/webpack/labels/documentation), +or [check out the issues on the documentation website's repository](https://github.com/webpack/webpack.js.org/issues). + +## Discussions + +Gitter is only for small questions. To discuss a subject in detail, please send a link to your forum or blog in the Gitter chat. + +## Join the development + +- Before you join development, please [set up the project](./_SETUP.md) on your local machine, run it and go through the application completely. Use any command you can find and see what it does. Explore. + + > Don't worry ... Nothing will happen to the project or to you due to the exploring. Only thing that will happen is, you'll be more familiar with what is where and might even get some cool ideas on how to improve various aspects of the project. + +- If you would like to work on an issue, drop in a comment at the issue. If it is already assigned to someone, but there is no sign of any work being done, please feel free to drop in a comment so that the issue can be assigned to you if the previous assignee has dropped it entirely. diff --git a/README.md b/README.md index 8f96a0a6d3b..c712d27fd7a 100644 --- a/README.md +++ b/README.md @@ -1,96 +1,136 @@ +
- webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset. -
+ Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset. +