Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f45ba24
remove items from runtime when unneeded
sokra Sep 30, 2019
69a545c
Deprecate MainTemplate, ChunkTemplate, ModuleTemplate
sokra Oct 2, 2019
0a4e52d
Avoid deprecated usage of ModuleTemplate
sokra Oct 2, 2019
ccc53db
update deprecated usage in library-related plugins
sokra Oct 2, 2019
53f68c9
update deprecated usage of chunk and main templates
sokra Oct 4, 2019
9e7844b
add "use strict" to all runtime modules
sokra Oct 7, 2019
f6e4dc6
terser defaults inherit ecma version
sokra Oct 7, 2019
ddc3dae
refactor Module.source() and Module.getRuntimeRequirements() into Mod…
sokra Oct 8, 2019
80bc311
remove "use strict" from runtime things for bundle size reasons
sokra Oct 8, 2019
f08c981
emit code generation errors in deterministic order
sokra Oct 9, 2019
d7dc764
filter DeprecationWarnings from captured stdio
sokra Oct 9, 2019
3e54494
remove supportsSymbolsDeconflicting
sokra Oct 9, 2019
4d425e7
remove unused file
sokra Oct 9, 2019
c156056
provide deprecated ModuleTemplate in ChunkTemplate hooks
sokra Oct 9, 2019
b7ad2b3
remove renderWithEntry hook and add render hook
sokra Oct 9, 2019
97079ba
add more compat hooks to MainTemplate
sokra Oct 9, 2019
36279de
fix compat hooks in ModuleTemplate, deprecate ModuleTemplate.runtimeT…
sokra Oct 9, 2019
ac9fca4
avoid creating an object for performance reasons
sokra Oct 9, 2019
84174fd
remove unneeded type
sokra Oct 9, 2019
b05a76e
lazy evaluate in WebpackOptionsApply
sokra Oct 9, 2019
6b67934
expose tapable plugins on export
sokra Oct 9, 2019
b4d782f
remove unused type
sokra Oct 9, 2019
922985b
fix error message
sokra Oct 9, 2019
ecbcdf5
apply chunk template modifications only to non-runtime chunks
sokra Oct 9, 2019
ee3e8da
export classes from webpack, and use them in webpack configs
sokra Oct 9, 2019
4f7e2da
add additional test case for variable leaking
sokra Oct 10, 2019
3f0920d
add additional compat layer for html-webpack-plugin compatibility
sokra Oct 10, 2019
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/node_modules
/test/js
/test/browsertest/js
/test/fixtures/temp-cache-fixture*
/test/fixtures/temp-*
/benchmark/js
/benchmark/fixtures
/examples/**/dist
Expand Down
9 changes: 9 additions & 0 deletions declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ declare namespace NodeJS {
}
}

// TODO remove when https://github.com/DefinitelyTyped/DefinitelyTyped/pull/38753 is merged
declare module "util" {
function deprecate<T extends Function>(
fn: T,
message: string,
code?: string
): T;
}

declare module "neo-async" {
interface QueueObject<T, E> {
push(item: T): void;
Expand Down
65 changes: 44 additions & 21 deletions declarations/WebpackOptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,10 @@ export interface Experiments {
* Support .mjs files as way to define strict ESM file (node.js)
*/
mjs?: boolean;
/**
* Allow outputing javascript files as module source type
*/
outputModule?: boolean;
/**
* Support WebAssembly as synchronous EcmaScript Module (outdated)
*/
Expand Down Expand Up @@ -1163,26 +1167,7 @@ export interface OutputOptions {
/**
* Add a comment in the UMD wrapper.
*/
auxiliaryComment?:
| string
| {
/**
* Set comment for `amd` section in UMD
*/
amd?: string;
/**
* Set comment for `commonjs` (exports) section in UMD
*/
commonjs?: string;
/**
* Set comment for `commonjs2` (module.exports) section in UMD
*/
commonjs2?: string;
/**
* Set comment for `root` (global variable) section in UMD
*/
root?: string;
};
auxiliaryComment?: string | LibraryCustomUmdCommentObject;
/**
* The callback function name used by webpack for loading of chunks in WebWorkers.
*/
Expand Down Expand Up @@ -1256,6 +1241,10 @@ export interface OutputOptions {
* The filename of the Hot Update Main File. It is inside the `output.path` directory.
*/
hotUpdateMainFilename?: string;
/**
* Wrap javascript code into IIFEs to avoid leaking into global scope.
*/
iife?: boolean;
/**
* The JSONP function used by webpack for async loading of chunks.
*/
Expand All @@ -1277,6 +1266,7 @@ export interface OutputOptions {
*/
libraryTarget?:
| "var"
| "module"
| "assign"
| "this"
| "window"
Expand All @@ -1291,6 +1281,10 @@ export interface OutputOptions {
| "umd2"
| "jsonp"
| "system";
/**
* Output javascript files as module source type.
*/
module?: boolean;
/**
* The output directory as **absolute path** (required).
*/
Expand All @@ -1302,7 +1296,12 @@ export interface OutputOptions {
/**
* The `publicPath` specifies the public URL address of the output files when referenced in a browser.
*/
publicPath?: string | Function;
publicPath?:
| string
| ((
pathData: import("../lib/Compilation").PathData,
assetInfo?: import("../lib/Compilation").AssetInfo
) => string);
/**
* The filename of the SourceMaps for the JavaScript files. They are inside the `output.path` directory.
*/
Expand All @@ -1324,6 +1323,30 @@ export interface OutputOptions {
*/
webassemblyModuleFilename?: string;
}
/**
* Set explicit comments for `commonjs`, `commonjs2`, `amd`, and `root`.
*
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "LibraryCustomUmdCommentObject".
*/
export interface LibraryCustomUmdCommentObject {
/**
* Set comment for `amd` section in UMD
*/
amd?: string;
/**
* Set comment for `commonjs` (exports) section in UMD
*/
commonjs?: string;
/**
* Set comment for `commonjs2` (module.exports) section in UMD
*/
commonjs2?: string;
/**
* Set comment for `root` (global variable) section in UMD
*/
root?: string;
}
/**
* This interface was referenced by `WebpackOptions`'s JSON-Schema
* via the `definition` "LibraryCustomUmdObject".
Expand Down
3 changes: 2 additions & 1 deletion examples/aggressive-merging/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var path = require("path");
var AggressiveMergingPlugin = require("../../lib/optimize/AggressiveMergingPlugin");
var { AggressiveMergingPlugin } = require("../../").optimize;

module.exports = {
// mode: "development" || "production",
entry: {
Expand Down
117 changes: 117 additions & 0 deletions examples/module/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# example.js

```javascript
import { increment as inc, value } from "./counter";
import { resetCounter, print } from "./methods";
print(value);
inc();
inc();
inc();
print(value);
resetCounter();
print(value);
```

# methods.js

```javascript
export { reset as resetCounter } from "./counter";

export const print = value => console.log(value);
```

# counter.js

```javascript
export let value = 0;
export function increment() {
value++;
}
export function decrement() {
value--;
}
export function reset() {
value = 0;
}
```

# dist/output.js

```javascript
/******/ "use strict";
/*!********************************!*\
!*** ./example.js + 2 modules ***!
\********************************/
/*! exports [not provided] [unused] */
/*! runtime requirements: supports-symbols-deconflicting */

// CONCATENATED MODULE: ./counter.js
let value = 0;
function increment() {
value++;
}
function decrement() {
value--;
}
function counter_reset() {
value = 0;
}

// CONCATENATED MODULE: ./methods.js


const print = value => console.log(value);

// CONCATENATED MODULE: ./example.js


print(value);
increment();
increment();
increment();
print(value);
counter_reset();
print(value);
```

# dist/output.js (production)

```javascript
let o=0;function n(){o++}const c=o=>console.log(o);c(o),n(),n(),n(),c(o),c(o=0);
```

# Info

## Unoptimized

```
Hash: 0a1b2c3d4e5f6a7b8c9d
Version: webpack 5.0.0-alpha.30
Asset Size Chunks Chunk Names
output.js 621 bytes {0} [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 429 bytes [entry] [rendered]
> ./example.js main
[0] ./example.js + 2 modules 429 bytes {0} [built]
[no exports]
[no exports used]
entry ./example.js main
used a library export
```

## Production mode

```
Hash: 0a1b2c3d4e5f6a7b8c9d
Version: webpack 5.0.0-alpha.30
Asset Size Chunks Chunk Names
output.js 80 bytes {179} [emitted] main
Entrypoint main = output.js
chunk {179} output.js (main) 429 bytes [entry] [rendered]
> ./example.js main
[291] ./example.js + 2 modules 429 bytes {179} [built]
[no exports]
[no exports used]
entry ./example.js main
used a library export
```
1 change: 1 addition & 0 deletions examples/module/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require("../build-common");
10 changes: 10 additions & 0 deletions examples/module/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export let value = 0;
export function increment() {
value++;
}
export function decrement() {
value--;
}
export function reset() {
value = 0;
}
9 changes: 9 additions & 0 deletions examples/module/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { increment as inc, value } from "./counter";
import { resetCounter, print } from "./methods";
print(value);
inc();
inc();
inc();
print(value);
resetCounter();
print(value);
3 changes: 3 additions & 0 deletions examples/module/methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { reset as resetCounter } from "./counter";

export const print = value => console.log(value);
43 changes: 43 additions & 0 deletions examples/module/template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# example.js

```javascript
_{{example.js}}_
```

# methods.js

```javascript
_{{methods.js}}_
```

# counter.js

```javascript
_{{counter.js}}_
```

# dist/output.js

```javascript
_{{dist/output.js}}_
```

# dist/output.js (production)

```javascript
_{{production:dist/output.js}}_
```

# Info

## Unoptimized

```
_{{stdout}}_
```

## Production mode

```
_{{production:stdout}}_
```
12 changes: 12 additions & 0 deletions examples/module/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
output: {
module: true
},
optimization: {
usedExports: true,
concatenateModules: true
},
experiments: {
outputModule: true
}
};
Loading