Commit Graph

775 Commits

Author SHA1 Message Date
Ivan Kopeykin cc0cd60909 more informative error when emitting multiple assets 2022-06-01 10:23:47 +03:00
Ivan Kopeykin cf5fc90082 support context in Dependency 2022-03-25 17:01:48 +03:00
Tobias Speicher 8f56fcba72
Replace deprecated String.prototype.substr()
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated.
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
2022-03-13 22:54:18 +01:00
Tobias Koppers 0d685d4e0b
Merge pull request #15413 from cool-little-fish/fix-15274
fix: use relative path in source map for context module
2022-03-08 08:07:54 +01:00
Tobias Koppers 15f8ba45c8 nitpick 2022-02-22 12:27:50 +01:00
Tobias Koppers 224964601d improve hashing 2022-02-22 12:23:24 +01:00
成仕伟 14478b90c8 fix: use relative path in source map for context module 2022-02-19 01:02:31 +08:00
Ivan Kopeykin cd3ec1da92 refactor top level declarations usage 2022-02-11 17:59:35 +03:00
Tobias Koppers 91dd188e01
Merge pull request #15187 from forivall/fix/addChunkInGroup-typings
fix: revise call signature of addChunkInGroup
2022-01-19 09:00:48 +01:00
Emily M Klassen d5bb62b68e doc: improve definition of addChunkInGroup via jsdoc 2022-01-18 15:44:17 -08:00
Ivan Kopeykin 453643af6d provide hashFunction parameter to DependencyTemplates 2022-01-18 13:42:13 +03:00
Asriel Yu 136b723023 fix callback err type should include null 2021-12-24 20:27:31 +08:00
Tobias Koppers 8ae9507196 add support for url() in css 2021-12-03 08:46:24 +01:00
Tobias Koppers 77b5589c1a css generation and hmr 2021-12-03 08:46:22 +01:00
Tobias Koppers 393fb6e22c fix a bug with experiments.cacheUnaffected
that causes missing invalidation for modules when only the module id has changed
2021-11-09 10:51:09 +01:00
Tobias Koppers 7afcc5d4ff allow to disable some deprecations
add `experiments.backCompat: false` (default in `experiments.futureDefaults`)
remove unused `experiments.asset`
enable `experiments.topLevelAwait` and `experiments.asyncWebAssembly` by default in `experiments.futureDefaults`
2021-11-05 09:54:51 +01:00
Tobias Koppers 8e283053c8
Merge pull request #14512 from h4l/bugfix/false-build-cycle-error
Fix incorrect BuildCycleError when loadModule() loads a module more than once
2021-10-19 00:22:34 +02:00
Hal Blackburn 8f2c266966 fix build cycle detection in Compilation
When tracking the modules which are being built by an origin module,
the code mistakenly adds the origin module itself to the set of modules
it's building, instead of the actual module about to be built. As a
result, when a module build finishes (and the module has itself called
loadModule()), it remains marked as building itself. So if it gets
loaded again, a BuildCycleError is reported despite no cycle existing.

Fixes #14379
2021-10-18 20:24:04 +01:00
Tobias Koppers 8a6fb50c6b avoid waiting for add module since that is not used with unsafe cache
fixes #14484
2021-10-18 12:42:49 +02:00
Tobias Koppers 80b1e77705 fix duplication due to unsafe cache 2021-10-12 22:46:50 +02:00
Tobias Koppers 1ee6f808d3 Revert "track chunk combinations for modules"
This reverts commit 0e13c7dea4.
2021-10-08 15:08:48 +02:00
Tobias Koppers 049b859879 compute depth faster 2021-10-07 16:13:42 +02:00
Tobias Koppers 0e13c7dea4 track chunk combinations for modules
improves caching
improves SplitChunksPlugin
2021-10-07 15:43:27 +02:00
Tobias Koppers 1e5abcc51b improve extractBlockModules 2021-10-06 15:39:21 +02:00
Tobias Koppers 2934fd0e3c add timing to second affected module computation 2021-10-06 10:24:12 +02:00
Tobias Koppers 07ad896f7a bugfix cacheUnaffected 2021-10-05 20:15:04 +02:00
Tobias Koppers f05246efcb use buildInfo instead of hash for cacheUnaffected 2021-10-05 15:09:39 +02:00
Tobias Koppers 91b6972144 add memCache2 for mem caching with module/chunk ids 2021-10-05 15:08:18 +02:00
Tobias Koppers 61569e26b9 compare references modules when restoring mem cache 2021-09-29 09:09:42 +02:00
Tobias Koppers 6c6e48c382 avoid RuntimeSpecMap in favor of directly setting on memCache 2021-09-29 00:06:44 +02:00
Tobias Koppers a82ab66fc1 fix accidentically shared mem caches 2021-09-28 23:52:25 +02:00
Tobias Koppers 931d14615f move unsafe cache from NormalModuleFactory to Compilation to skip more processing 2021-09-28 11:37:29 +02:00
Tobias Koppers c33a64bb23 enable to use mem cache for dependency caching 2021-09-27 20:41:24 +02:00
Tobias Koppers 16fc4bb7af allow dependencies to select level of propagation 2021-09-27 20:38:08 +02:00
Tobias Koppers 2393892434 assign each module it's own mem cache
instead of receiving a per module node per access
2021-09-27 20:37:30 +02:00
Tobias Koppers 3b48429eb5 add MemCache for memory caching per module which is invalidated when module or any referenced modules changes
add `experiments.cacheUnaffected`
add `cache.cacheUnaffected` (type: memory) resp `cache.memoryCacheUnaffected` (type: filesystem)
2021-09-24 15:23:29 +02:00
Tobias Koppers 4a8bf4c084 allow to configure all hash functions used
fix default hash function for HttpUriPlugin to sha512
2021-09-23 14:55:13 +02:00
Tobias Koppers b16568a253 upgrade filename runtime module to full hash module when referencing a full hash chunk 2021-09-02 10:29:59 +02:00
hdineen c3e4e17322 Pass module to `Compilation.addModuleChain` callback when applicable
Although the callbacks for the `addModuleChain` and `addModuleTree` methods
are of type `ModuleCallback`, the `result` parameter is always `undefined`.
2021-08-16 15:40:35 -04:00
Tobias Koppers c6856e2204 optional modules will not fail the build when bail is set
fixes #11594
2021-08-06 12:09:55 +02:00
Tobias Koppers b6609a4f6b add `experiments.buildHttp`
allows to build remote resources
stores remote resources in a lockfile
2021-08-05 15:47:18 +02:00
Tobias Koppers 0ae059fb3f limit the number of parallel generated chunks 2021-08-05 10:57:53 +02:00
Tobias Koppers 8dd38f5c8a refactor 2021-07-16 13:05:18 +02:00
Mark Molinaro 41f02f947a perf: let Compiler worry about and manage file and context timestamps 2021-07-13 22:13:40 +00:00
Tobias Koppers 273bd8f575 move defineRemovedModuleTemplates into separate function as it leaks memory in the feedback vectors 2021-06-17 10:11:24 +02:00
Tobias Koppers f5fac83c08 clear compilation queues to reduce memory usage 2021-06-17 10:10:51 +02:00
Tobias Koppers b0fa9ccada pretty files 2021-05-11 09:31:46 +02:00
Tobias Koppers 87c0d1cd94 Merge branch 'master' into johnnyreilly/master 2021-05-07 18:07:23 +02:00
Tobias Koppers a060126e49 improve module dependency processing performance 2021-04-28 10:27:51 +02:00
Tobias Koppers 89d6dcb0e2 used cached value 2021-04-28 09:10:44 +02:00
Tobias Koppers 7cc40782b7 fix some internal types 2021-04-22 21:48:25 +02:00
Tobias Koppers 2df8267220 handle falsy entry options correctly 2021-04-14 20:21:17 +02:00
Tobias Koppers 52178a5aee
Merge pull request #13134 from webpack/bugfix/hmr-in-execute-module
importModule & HMR
2021-04-14 16:55:37 +02:00
Tobias Koppers f46e816a38 add HMR test case and fix problems with it 2021-04-14 16:03:59 +02:00
Tobias Koppers 24c5902374 add interceptModuleExecution, module cache and improve error messages 2021-04-14 14:37:00 +02:00
Tobias Koppers d808d04d26 attach the chunk graph to RuntimeModules 2021-04-14 12:26:35 +02:00
Tobias Koppers bbcc5a8ebe add caching on ModuleGraph
cache star reexport assignment
2021-04-14 09:11:23 +02:00
Tobias Koppers 03961f3391
Merge pull request #13102 from webpack/feature/built-time-execution 2021-04-12 15:00:32 +02:00
Tobias Koppers 33c862e07b emit assets from modules during executing modules 2021-04-12 12:42:25 +02:00
Tobias Koppers ea3e0a39ac add experiments.executeModule
rename runModule -> executeModule
improve error reporting
2021-04-12 12:27:55 +02:00
Tobias Koppers 1d35cf13e3 fix cache dependencies, assets and persistent caching 2021-04-12 12:27:54 +02:00
Tobias Koppers 065177df66 add experimental support for build time execution
allow to execute a part of the module graph at build time
e. g. to generate code or other assets

loaders have access to that via `this.importModule(request, options)`
2021-04-12 12:27:54 +02:00
Tobias Koppers 33b44a05ea DefinePlugin invalidates modules when new defines are added
fixes https://github.com/vercel/next.js/issues/23901
2021-04-12 12:23:51 +02:00
Tobias Koppers 324a46d908 Revert "dispose code generation results after sealing the compilation"
This reverts commit cef2a8fea0.
2021-04-09 19:50:13 +02:00
Tobias Koppers cef2a8fea0 dispose code generation results after sealing the compilation 2021-04-08 18:33:51 +02:00
Tobias Koppers 3caf3e95a8 avoid leaking processed assets 2021-04-07 20:48:07 +02:00
Tobias Koppers 103a51468b DefinePlugin takes care of module invalidation when values have changed
The options of the DefinePlugin no longer have to be covered by build dependencies
2021-03-15 15:19:42 +01:00
Tobias Koppers 85a6eee0bb move parser.filename back to generator.filename 2021-03-11 17:19:11 +01:00
Tobias Koppers c7f93af138 refactor startup logic to better integrate with libraries
get rid of startupNoDefault and many custom logic regarding this in jsonp chunk loading
add onChunksLoaded runtime method to cover that for all chunk loading types
add `__webpack_runtime_id__` to access the current runtime
allow to use onChunksLoaded for other module types too
2021-03-08 20:25:09 +01:00
Tobias Koppers 9efce4bd84
Merge pull request #12761 from zollero/master
Fix letter spelling of missing a 's'
2021-02-23 22:48:10 +01:00
Tobias Koppers 1a584d3148 ensure all successful compiled modules are persistent cached
fix some test cases and code to ensure this is true
2021-02-23 15:36:53 +01:00
Zollero bb1d319a8a
fix letter spelling of missing a 's'
fix letter spelling of missing a 's'
2021-02-23 19:23:50 +08:00
Tobias Koppers 0b4506b206 improve typings for loggingDebug and other filtering configuration options 2021-02-22 13:18:27 +01:00
Tobias Koppers 9b448c14d9 debug logging should be included in stats even if stats.logging is false 2021-02-22 12:53:52 +01:00
Tobias Koppers ca0df823c8 order runtime chunks correctly for hashing
fixes #12676
2021-02-14 21:59:45 +01:00
Tobias Koppers d65f3bbf0d fix crash when all modules of an entrypoint fail resolving and another entrypoint dependOn it 2021-02-10 15:40:11 +01:00
Tobias Koppers 93931241ba
Merge pull request #12567 from mattcompiles/fix-broken-rebuild 2021-02-03 14:41:42 +01:00
Matt Jones d39cbe2ee6 Fix module rebuilds that add new dependencies 2021-02-03 08:40:20 +11:00
Tobias Koppers 3e1c7082d2 log out module profile summary when profiling is enabled 2021-02-02 03:29:21 +01:00
Tobias Koppers f25345cae9 refactor code generation and HMR plugin to generate real module hashes for HMR 2021-01-26 14:45:11 +01:00
Sam Cooke ea4e298efe Self-review, add chunkGraph 2021-01-13 12:53:37 +01:00
Sam Cooke a1a536ceb0 Linting 2021-01-13 12:53:37 +01:00
Sam Cooke 13af82bb9e Fix failing test 2021-01-13 12:53:36 +01:00
Tobias Koppers 10aa3daede add experiments.layers
add layers to define different module layers
support module layers in stats

add layer support for NormalModules

fixes #11466
2021-01-05 20:50:59 +01:00
Tobias Koppers b5b1f25ad2 improve typings for stats related hooks and classes 2020-12-17 18:51:55 +01:00
Tobias Koppers 63dda151a2 expose Asset and AssetInfo types
allow custom properties in AssetInfo
2020-12-17 10:27:18 +01:00
Tobias Koppers 1c7f221e0a fix triggering processAssets for some assets twice 2020-12-10 17:40:12 +01:00
Tobias Koppers c2069f8db7 fix handling of multiple identical assets with different querystrings
fixes #11894
2020-12-09 16:10:32 +01:00
Tobias Koppers ccfe01aab4 allow to process assets that are added during processAssets
fix and add processAsset stages

allow to hook into RealContentHashPlugin for custom hashing
2020-11-26 14:00:21 +01:00
Tobias Koppers eb5481adfb
Merge pull request #11948 from jantimon/fix/plugin-types
fixes "Type '(compiler: Compiler) => void' is not assignable to type '() => void'.ts"
2020-11-26 13:56:41 +01:00
Tobias Koppers cbcd459d19 fix conflicting real imports and type imports 2020-11-26 10:02:59 +01:00
Hiroki Osame 1422f2400d docs(type): documented minimized property on asset-info 2020-11-11 01:15:35 -05:00
Jan Nicklas d12b043c3d fix: adjust typings to resolve "Type '(compiler: Compiler) => void' is not assignable to type '() => void'.ts 2020-11-09 14:54:40 +01:00
Tobias Koppers 19f51535ca merge multiple import statements with different conditions correctly
improve hashing when conditional runtime evaluation is involved
add test cases
2020-10-27 06:48:54 +01:00
Tobias Koppers 7661ad868a generate code that executes depending on runtime
fixes #11770
2020-10-27 06:30:49 +01:00
Tobias Koppers 2ec90b3687 add asset info for `sourceFilename` and `javascriptModule` 2020-10-22 10:47:23 +02:00
Tobias Koppers 204caeee05 fix order of asset optimization to fix conflict between compression-plugin and real hash plugin 2020-10-16 14:42:46 +02:00
Tobias Koppers 63ba54c109 update chunk to files mapping when deleting assets 2020-10-15 14:27:23 +02:00
Tobias Koppers 45040463c6 order runtime chunks correctly when they depend on each other 2020-10-14 21:19:50 +02:00
Christian Brueggemann 51f8069907 Try to fix lint errors 2020-10-06 17:55:22 +02:00
Christian Brueggemann f7e6f2a02a Remove own implementation of Array equals 2020-10-06 17:48:13 +02:00
Christian Brueggemann 302db2a1f8 Try to fix lint errors 2020-10-06 17:42:03 +02:00
Christian Brüggemann 3aac3350a8
Fix compilation of projects where dependsOn is an array
An entrypoint can be defined with `dependOn` specified as an array (see docs)[https://webpack.js.org/configuration/entry-context/#entry], for example:

```javascript
 splitmodule1: {
                import: scanSourceFiles('./src/splitmodule1'),
                dependOn: [ 'pluginregistry'] // Note that we could specify multiple dependencies here, e.g. dependOn: ['core', 'pluginregistry']
 }
```
Using the Webpack Watcher results in the following error:

```
× 「wdm」: Error: Conflicting entry option dependOn = pluginregistry vs pluginregistry
    at Compilation._addEntryItem (C:\Users\c.brueggemann\Documents\Projects\codesplit\node_modules\webpack\lib\Compilation.js:1616:7)
    at Compilation.addEntry (C:\Users\c.brueggemann\Documents\Projects\codesplit\node_modules\webpack\lib\Compilation.js:1560:8)
    at C:\Users\c.brueggemann\Documents\Projects\codesplit\node_modules\webpack\lib\DynamicEntryPlugin.js:59:23
    at new Promise (<anonymous>)
    at C:\Users\c.brueggemann\Documents\Projects\codesplit\node_modules\webpack\lib\DynamicEntryPlugin.js:58:10
```

This PR fixes the crash by comparing the arrays deeply instead of using incorrectly comparing them using `===`. I'm not too familiar with Webpack, so I'll be happy to adjust according to feedback.
2020-10-06 16:28:06 +02:00
Tobias Koppers 07fc554bef improve warnings and errors handling in stats
respect warningsFilter for warnings count
include child compilation warnings and errors in count
show hint for child compilation errors and warnings
2020-09-20 21:24:15 +02:00
Tobias Koppers ed06a7f83a new Worker() support
add support for async anonymous entrypoints from inside the codebase
add worker example
move entry options into Entrypoint and receive them from there
2020-09-08 07:37:20 +02:00
Tobias Koppers b6bfe8b891 fix auxiliary files for Compilation.renameAsset 2020-09-03 23:24:16 +02:00
Tobias Koppers 8497cd34c6 move start and endTime from Stats to Compilation 2020-09-03 22:01:25 +02:00
Tobias Koppers 0f089187e4 improve hashing of runtime modules that need a full hash 2020-09-01 18:31:29 +02:00
Tobias Koppers be021e00f4 add grouping of modules 2020-09-01 18:31:22 +02:00
Tobias Koppers dff76973e4 type fixes 2020-08-24 18:35:28 +02:00
Tobias Koppers cee47dc867 Store cache dependencies inside of Snapshot to reduce cache size 2020-08-24 18:16:54 +02:00
Tobias Koppers 114154099c avoid merging LazySets from factory results 2020-08-24 18:16:52 +02:00
Tobias Koppers 6409463d24 only create shared snapshots for 3 or more shared entries
add logging
2020-08-24 18:16:50 +02:00
Tobias Koppers b929d4cdce calculate real content hash for assets after asset processing 2020-08-18 22:07:24 +02:00
Tobias Koppers 62ccae1abd build errors should be errors even for optional modules
optional modules should only treat "not found" errors as warnings

fixes #9161
2020-08-14 20:03:48 +02:00
Tobias Koppers f9fe121fc8 improve and add statistics 2020-08-14 10:51:12 +02:00
Tobias Koppers a42e636a9c handle case where assets are related from multiple assets 2020-08-07 15:24:49 +02:00
Tobias Koppers 84aeac5c92 add Compilation.deleteAsset 2020-08-06 09:55:18 +02:00
Tobias Koppers f5bd6216aa add related info to asset info 2020-08-02 07:36:05 +02:00
Tobias Koppers fdfaa2efa0
Merge pull request #11252 from webpack/improve/cache-and-progress
do cache related tasks after calling handler in watching
2020-08-01 19:11:48 +02:00
Tobias Koppers ca369f23c5 do cache related tasks after calling handler in watching
improve progress output
2020-08-01 09:00:17 +02:00
Tobias Koppers 9e81495f7b add useful error messages for runtime and dependsOn 2020-08-01 06:43:16 +02:00
Tobias Koppers 216ab35823 avoid storing code generation result on errors 2020-07-28 22:09:31 +02:00
Tobias Koppers 3465b00a62 performance, cleanup 2020-07-28 22:05:13 +02:00
Tobias Koppers 1265765141 polish, types 2020-07-27 22:41:04 +02:00
Tobias Koppers e16bdfda6c refactor used exports analysis, hashing, code generation, optimizations
to keep track of runtimes, used exports depending on runtime

modules can have different hashes and generated code depending on runtime
chunks are only considered as equal for MergeDuplicateChunks and SplitChunks when exports used in contained modules are equal
added `optimization.usedExports: "global"` to opt-out from used exports analysis per runtime
added `splitChunks.usedExports` and `splitChunks.cacheGroups[x].usedExports` to enable/disable used exports comparing for modules
`splitChunks.usedExports` defaults to `true` in production
2020-07-27 22:40:44 +02:00
Tobias Koppers b3466e996b add entry[x].runtime option to allow runtime chunk per entry 2020-07-27 22:40:40 +02:00
Tobias Koppers 36cf3039aa use content hashes for assets 2020-07-20 08:45:27 +02:00
Tobias Koppers b1eac4ab29 Use computed resolve options in context alternatives
deprecate ContextModuleFactory.hooks.alternatives because we need the options in the hook
2020-07-15 14:13:35 +02:00
Tobias Koppers fd9b399ae9 Create Cache facade to make it easier to use
add missing serializers for classes used in test suite
2020-07-15 11:14:28 +02:00
Tobias Koppers 555db6a547 remove Compilation.modifyHash
refactor HMR Plugin to better support module hashes

fixes bug that causes empty HMR manifest
remove HotModuleReplacementPlugin multiStep
2020-07-09 09:02:38 +02:00
Tobias Koppers 23f922bed3 make bundles with Module Federation more stable 2020-07-02 15:28:17 +02:00
Tobias Koppers 4c1ad1ee7d reduce calls to getter 2020-06-17 23:01:18 +02:00
Ivan Kopeykin 198e51a485 Merge branch 'master' into exports-field
# Conflicts:
#	lib/dependencies/ImportDependency.js
#	lib/sharing/ConsumeSharedPlugin.js
#	lib/sharing/ProvideSharedPlugin.js
#	types.d.ts
2020-06-16 21:16:41 +03:00
Tobias Koppers c00fec3aa7
Merge pull request #10964 from pushkar100/feature/lazy-load-named-exports
Lazy loading only required exports from dynamic import()
2020-06-16 15:04:06 +02:00
Pushkar DK 31e3369a73 Add 'webpackExports' & make only referenced exports available in import() 2020-06-06 00:11:21 +05:30
Ryan Graff 8cebd62722
chore(Compilation EntryData includeDependencies):
Correct a grammatical error in the description.
2020-06-05 00:42:33 -04:00
Tobias Koppers 3df380e2d7 add script external
change defaults of ModuleFederationPlugin to var library and script remoteType
allow using empty entry in config
2020-06-04 03:18:07 +02:00
Ivan Kopeykin 57bd6ed348 Merge branch 'master' into exports-field
# Conflicts:
#	lib/container/OverridablesPlugin.js
2020-06-01 15:14:47 +03:00
Ivan Kopeykin a7b85301a7 add explanation for processDependency method 2020-05-31 00:56:12 +03:00
Ivan Kopeykin 4af609a38c fix resource identifier in Compilation and resolveLoader options 2020-05-28 10:53:28 +03:00
Ivan Kopeykin 0dd9aaf25b fix combining dependencies in Compilation
remove extra layer, use concatenated key instead
2020-05-28 01:23:54 +03:00
Ivan Kopeykin 8c1d64c5fd rework how condition names pass to resolve option 2020-05-27 02:27:52 +03:00
Tobias Koppers e44e51fa5b bugfix some edge cases 2020-05-26 18:08:16 +02:00
Tobias Koppers a468cbbd2e add provide shared module plugin 2020-05-23 16:08:51 +02:00
Tobias Koppers 49752a06a8 cleanup asset processing
deprecate writing to compilation.assets after sealing.
merge all asset processing into single hook with stages.
Deprecate additionalChunkAssets and optimizeChunkAssets.
Redirect additionalAssets, optimizeAssets to processAssets for backward-compat.
Remove finishAssets hook without deprecation as it was not in v4.
2020-05-22 10:39:21 +02:00
Tobias Koppers 15eefadcea
Merge pull request #10838 from webpack/dev-1
Merge Module Federation into webpack 5 beta
2020-05-05 23:57:00 +02:00
Tobias Koppers 93fddc0680 remove logic to finish modules in module graph 2020-05-05 22:12:27 +02:00
Tobias Koppers 24d1ca50b7 generate useful module ids for container-related modules 2020-05-05 21:51:17 +02:00
Tobias Koppers 50ec72a6ca use the full hash on modules that need the full hash of the compilation
use getFullHash runtime module for updating the hash in HMR
2020-04-30 17:57:01 +02:00