Skip to content

Commit f33c2b0

Browse files
authored
Merge branch 'webpack:main' into main
2 parents 2cad865 + a3f49f3 commit f33c2b0

File tree

76 files changed

+548
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+548
-107
lines changed

.github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
node-version: 17.x
2828
cache: "yarn"
2929
- run: yarn --frozen-lockfile
30-
- uses: actions/cache@v1
30+
- uses: actions/cache@v3
3131
with:
3232
path: .eslintcache
3333
key: lint-${{ env.GITHUB_SHA }}
@@ -62,7 +62,7 @@ jobs:
6262
- run: yarn --frozen-lockfile
6363
- run: yarn link --frozen-lockfile || true
6464
- run: yarn link webpack --frozen-lockfile
65-
- uses: actions/cache@v1
65+
- uses: actions/cache@v3
6666
with:
6767
path: .jest-cache
6868
key: jest-unit-${{ env.GITHUB_SHA }}
@@ -101,7 +101,7 @@ jobs:
101101
- run: yarn --frozen-lockfile
102102
- run: yarn link --frozen-lockfile || true
103103
- run: yarn link webpack --frozen-lockfile
104-
- uses: actions/cache@v2
104+
- uses: actions/cache@v3
105105
with:
106106
path: .jest-cache
107107
key: jest-integration-${{ env.GITHUB_SHA }}

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ or are automatically applied via regex from your webpack configuration.
158158

159159
#### Transpiling
160160

161-
| Name | Status | Install Size | Description |
162-
| :--------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------: | :------------: | :------------------------------------------------------------------------------------------------ |
163-
| <a href="https://github.com/babel/babel-loader"><img width="48" height="48" title="babel-loader" src="https://worldvectorlogo.com/logos/babel-10.svg"></a> | ![babel-npm] | ![babel-size] | Loads ES2015+ code and transpiles to ES5 using <a href="https://github.com/babel/babel">Babel</a> |
164-
| <a href="https://github.com/TypeStrong/ts-loader"><img width="48" height="48" src="https://cdn.rawgit.com/Microsoft/TypeScript/master/doc/logo.svg"></a> | ![type-npm] | ![type-size] | Loads TypeScript like JavaScript |
165-
| <a href="https://github.com/webpack-contrib/coffee-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a> | ![coffee-npm] | ![coffee-size] | Loads CoffeeScript like JavaScript |
161+
| Name | Status | Install Size | Description |
162+
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------: | :------------: | :------------------------------------------------------------------------------------------------ |
163+
| <a href="https://github.com/babel/babel-loader"><img width="48" height="48" title="babel-loader" src="https://worldvectorlogo.com/logos/babel-10.svg"></a> | ![babel-npm] | ![babel-size] | Loads ES2015+ code and transpiles to ES5 using <a href="https://github.com/babel/babel">Babel</a> |
164+
| <a href="https://github.com/TypeStrong/ts-loader"><img width="48" height="48" src="https://raw.githubusercontent.com/microsoft/TypeScript-Website/f407e1ae19e5e990d9901ac8064a32a8cc60edf0/packages/typescriptlang-org/static/branding/ts-logo-128.svg"></a> | ![type-npm] | ![type-size] | Loads TypeScript like JavaScript |
165+
| <a href="https://github.com/webpack-contrib/coffee-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a> | ![coffee-npm] | ![coffee-size] | Loads CoffeeScript like JavaScript |
166166

167167
[babel-npm]: https://img.shields.io/npm/v/babel-loader.svg
168168
[babel-size]: https://packagephobia.com/badge?p=babel-loader
@@ -175,7 +175,7 @@ or are automatically applied via regex from your webpack configuration.
175175

176176
| Name | Status | Install Size | Description |
177177
| :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------: | :--------------: | :-------------------------------------------------------------------------------------- |
178-
| <a href="https://github.com/webpack-contrib/html-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/html5.svg"></a> | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources |
178+
| <a href="https://github.com/webpack-contrib/html-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/html5-2.svg"></a> | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources |
179179
| <a href="https://github.com/pugjs/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a> | ![pug-npm] | ![pug-size] | Loads Pug templates and returns a function |
180180
| <a href="https://github.com/webdiscus/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a> | ![pug3-npm] | ![pug3-size] | Compiles Pug to a function or HTML string, useful for use with Vue, React, Angular |
181181
| <a href="https://github.com/peerigon/markdown-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/markdown.svg"></a> | ![md-npm] | ![md-size] | Compiles Markdown to HTML |

bin/webpack.js

+13
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ const isInstalled = packageName => {
5353
}
5454
} while (dir !== (dir = path.dirname(dir)));
5555

56+
// https://github.com/nodejs/node/blob/v18.9.1/lib/internal/modules/cjs/loader.js#L1274
57+
// eslint-disable-next-line no-warning-comments
58+
// @ts-ignore
59+
for (const internalPath of require("module").globalPaths) {
60+
try {
61+
if (fs.statSync(path.join(internalPath, packageName)).isDirectory()) {
62+
return true;
63+
}
64+
} catch (_error) {
65+
// Nothing
66+
}
67+
}
68+
5669
return false;
5770
};
5871

declarations.d.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,20 @@ declare module "@webassemblyjs/ast" {
246246
declare module "webpack-sources" {
247247
export type MapOptions = { columns?: boolean; module?: boolean };
248248

249+
export type RawSourceMap = {
250+
version: number;
251+
sources: string[];
252+
names: string[];
253+
sourceRoot?: string;
254+
sourcesContent?: string[];
255+
mappings: string;
256+
file: string;
257+
};
258+
249259
export abstract class Source {
250260
size(): number;
251261

252-
map(options?: MapOptions): Object;
262+
map(options?: MapOptions): RawSourceMap | null;
253263

254264
sourceAndMap(options?: MapOptions): {
255265
source: string | Buffer;

declarations/LoaderContext.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ export interface LoaderRunnerLoaderContext<OptionsType> {
212212
* Example: "/abc/resource.js?query#frag"
213213
*/
214214
resource: string;
215+
216+
/**
217+
* Target of compilation.
218+
* Example: "web"
219+
*/
220+
target: string;
215221
}
216222

217223
type AdditionalData = {

examples/chunkhash/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import("./async2");
2020
```javascript
2121
var path = require("path");
2222
module.exports = {
23-
// mode: "development || "production",
23+
// mode: "development" || "production",
2424
entry: {
2525
main: "./example"
2626
},

examples/chunkhash/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var path = require("path");
22
module.exports = {
3-
// mode: "development || "production",
3+
// mode: "development" || "production",
44
entry: {
55
main: "./example"
66
},

examples/coffee-script/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
// mode: "development || "production",
2+
// mode: "development" || "production",
33
module: {
44
rules: [
55
{

examples/common-chunk-grandchildren/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module.exports = function() {
8686
const path = require("path");
8787

8888
module.exports = {
89-
// mode: "development || "production",
89+
// mode: "development" || "production",
9090
entry: {
9191
main: ["./example.js"]
9292
},

examples/common-chunk-grandchildren/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const path = require("path");
33

44
module.exports = {
5-
// mode: "development || "production",
5+
// mode: "development" || "production",
66
entry: {
77
main: ["./example.js"]
88
},

examples/dll-app-and-vendor/0-vendor/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var path = require("path");
1313
var webpack = require("../../../");
1414

1515
module.exports = {
16-
// mode: "development || "production",
16+
// mode: "development" || "production",
1717
context: __dirname,
1818
entry: ["example-vendor"],
1919
output: {

examples/dll-app-and-vendor/0-vendor/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var path = require("path");
22
var webpack = require("../../../");
33

44
module.exports = {
5-
// mode: "development || "production",
5+
// mode: "development" || "production",
66
context: __dirname,
77
entry: ["example-vendor"],
88
output: {

examples/dll-user/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This is the _user_ bundle, which uses the manifest from [dll-reference example](
1010
var path = require("path");
1111
var webpack = require("../../");
1212
module.exports = {
13-
// mode: "development || "production",
13+
// mode: "development" || "production",
1414
plugins: [
1515
new webpack.DllReferencePlugin({
1616
context: path.join(__dirname, "..", "dll"),

examples/dll-user/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var path = require("path");
22
var webpack = require("../../");
33
module.exports = {
4-
// mode: "development || "production",
4+
// mode: "development" || "production",
55
plugins: [
66
new webpack.DllReferencePlugin({
77
context: path.join(__dirname, "..", "dll"),

examples/dll/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This is the _reference_ bundle (with the manifests) for [dll user example](https
1010
var path = require("path");
1111
var webpack = require("../../");
1212
module.exports = {
13-
// mode: "development || "production",
13+
// mode: "development" || "production",
1414
resolve: {
1515
extensions: [".js", ".jsx"]
1616
},

examples/dll/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var path = require("path");
22
var webpack = require("../../");
33
module.exports = {
4-
// mode: "development || "production",
4+
// mode: "development" || "production",
55
resolve: {
66
extensions: [".js", ".jsx"]
77
},

examples/explicit-vendor-chunk/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var webpack = require("../../");
66
module.exports = [
77
{
88
name: "vendor",
9-
// mode: "development || "production",
9+
// mode: "development" || "production",
1010
entry: ["./vendor", "./vendor2"],
1111
output: {
1212
path: path.resolve(__dirname, "dist"),
@@ -23,7 +23,7 @@ module.exports = [
2323

2424
{
2525
name: "app",
26-
// mode: "development || "production",
26+
// mode: "development" || "production",
2727
dependencies: ["vendor"],
2828
entry: {
2929
pageA: "./pageA",

examples/explicit-vendor-chunk/webpack.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var webpack = require("../../");
33
module.exports = [
44
{
55
name: "vendor",
6-
// mode: "development || "production",
6+
// mode: "development" || "production",
77
entry: ["./vendor", "./vendor2"],
88
output: {
99
path: path.resolve(__dirname, "dist"),
@@ -20,7 +20,7 @@ module.exports = [
2020

2121
{
2222
name: "app",
23-
// mode: "development || "production",
23+
// mode: "development" || "production",
2424
dependencies: ["vendor"],
2525
entry: {
2626
pageA: "./pageA",

examples/externals/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ exports.exampleValue = subtract(add(42, 2), 2);
2828

2929
```javascript
3030
module.exports = {
31-
// mode: "development || "production",
31+
// mode: "development" || "production",
3232
output: {
3333
libraryTarget: "umd"
3434
},

examples/externals/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
// mode: "development || "production",
2+
// mode: "development" || "production",
33
output: {
44
libraryTarget: "umd"
55
},

examples/extra-async-chunk-advanced/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require.ensure(["./a", "./e"], function(require) {
2323

2424
```javascript
2525
module.exports = {
26-
// mode: "development || "production",
26+
// mode: "development" || "production",
2727
optimization: {
2828
splitChunks: {
2929
minSize: 0 // This example is too small

examples/extra-async-chunk-advanced/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
// mode: "development || "production",
2+
// mode: "development" || "production",
33
optimization: {
44
splitChunks: {
55
minSize: 0 // This example is too small

examples/extra-async-chunk/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
// mode: "development || "production",
2+
// mode: "development" || "production",
33
optimization: {
44
splitChunks: {
55
minSize: 0 // This example is too small

examples/harmony-library/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
```javascript
44
var path = require("path");
55
module.exports = {
6-
// mode: "development || "production",
6+
// mode: "development" || "production",
77
entry: "./example",
88
output: {
99
path: path.join(__dirname, "dist"),

examples/harmony-library/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var path = require("path");
22
module.exports = {
3-
// mode: "development || "production",
3+
// mode: "development" || "production",
44
entry: "./example",
55
output: {
66
path: path.join(__dirname, "dist"),

examples/harmony-unused/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
// mode: "development || "production",
2+
// mode: "development" || "production",
33
optimization: {
44
concatenateModules: false
55
}

examples/http2-aggressive-splitting/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The backward compatibility (non-HTTP2 client) improves with bigger `maxSize`, as
2020
var path = require("path");
2121
var webpack = require("../../");
2222
module.exports = {
23-
// mode: "development || "production",
23+
// mode: "development" || "production",
2424
cache: true, // better performance for the AggressiveSplittingPlugin
2525
entry: "./example",
2626
output: {

examples/http2-aggressive-splitting/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var path = require("path");
22
var webpack = require("../../");
33
module.exports = {
4-
// mode: "development || "production",
4+
// mode: "development" || "production",
55
cache: true, // better performance for the AggressiveSplittingPlugin
66
entry: "./example",
77
output: {

examples/hybrid-routing/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
```javascript
44
var path = require("path");
55
module.exports = {
6-
// mode: "development || "production",
6+
// mode: "development" || "production",
77
entry: {
88
// The entry points for the pages
99
// They also contains router

examples/hybrid-routing/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var path = require("path");
22
module.exports = {
3-
// mode: "development || "production",
3+
// mode: "development" || "production",
44
entry: {
55
// The entry points for the pages
66
// They also contains router

examples/loader/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
// mode: "development || "production",
2+
// mode: "development" || "production",
33
module: {
44
rules: [
55
{

examples/many-pages/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Note: decreasing `maxInitial/AsyncRequest` will increase duplication further to
2626

2727
```
2828
module.exports = {
29-
// mode: "development || "production",
29+
// mode: "development" || "production",
3030
entry: {
3131
pageA: "./pages/a",
3232
pageB: "./pages/b",

examples/many-pages/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
// mode: "development || "production",
2+
// mode: "development" || "production",
33
entry: {
44
pageA: "./pages/a",
55
pageB: "./pages/b",

examples/multi-compiler/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var webpack = require("../../");
1515
module.exports = [
1616
{
1717
name: "mobile",
18-
// mode: "development || "production",
18+
// mode: "development" || "production",
1919
entry: "./example",
2020
output: {
2121
path: path.join(__dirname, "dist"),
@@ -30,7 +30,7 @@ module.exports = [
3030

3131
{
3232
name: "desktop",
33-
// mode: "development || "production",
33+
// mode: "development" || "production",
3434
entry: "./example",
3535
output: {
3636
path: path.join(__dirname, "dist"),

examples/multi-compiler/webpack.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var webpack = require("../../");
33
module.exports = [
44
{
55
name: "mobile",
6-
// mode: "development || "production",
6+
// mode: "development" || "production",
77
entry: "./example",
88
output: {
99
path: path.join(__dirname, "dist"),
@@ -18,7 +18,7 @@ module.exports = [
1818

1919
{
2020
name: "desktop",
21-
// mode: "development || "production",
21+
// mode: "development" || "production",
2222
entry: "./example",
2323
output: {
2424
path: path.join(__dirname, "dist"),

0 commit comments

Comments
 (0)