Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make packages webpack 5 compatible #638

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions packages/component/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"dist/loadable.cjs.js": {
"bundled": 14563,
"minified": 7172,
"gzipped": 2534
"bundled": 16387,
"minified": 7324,
"gzipped": 2574
},
"dist/loadable.esm.js": {
"bundled": 14184,
"minified": 6868,
"gzipped": 2467,
"bundled": 16008,
"minified": 7020,
"gzipped": 2506,
"treeshaked": {
"rollup": {
"code": 276,
"import_statements": 276
},
"webpack": {
"code": 5744
"code": 5896
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions packages/server/src/ChunkExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,20 @@ class ChunkExtractor {
}

createChunkAsset({ filename, chunk, type, linkType }) {
const resolvedFilename =
typeof filename === 'object' && filename.name ? filename.name : filename

return {
filename,
filename: resolvedFilename,
scriptType: extensionToScriptType(
path
.extname(filename)
.extname(resolvedFilename)
.split('?')[0]
.toLowerCase(),
),
chunk,
url: this.resolvePublicUrl(filename),
path: path.join(this.outputPath, filename),
url: this.resolvePublicUrl(resolvedFilename),
path: path.join(this.outputPath, resolvedFilename),
type,
linkType,
}
Expand Down
10 changes: 8 additions & 2 deletions packages/webpack-plugin/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ class LoadablePlugin {
apply(compiler) {
this.compiler = compiler

// Add a custom output.jsonpFunction: __LOADABLE_LOADED_CHUNKS__
compiler.options.output.jsonpFunction = '__LOADABLE_LOADED_CHUNKS__'
// Check if webpack version 4 or 5
if ('jsonpFunction' in compiler.options.output) {
// Add a custom output.jsonpFunction: __LOADABLE_LOADED_CHUNKS__
compiler.options.output.jsonpFunction = '__LOADABLE_LOADED_CHUNKS__'
} else {
// Add a custom output.chunkLoadingGlobal: __LOADABLE_LOADED_CHUNKS__
compiler.options.output.chunkLoadingGlobal = '__LOADABLE_LOADED_CHUNKS__'
}

if (this.opts.outputAsset || this.opts.writeToDisk) {
compiler.hooks.emit.tapAsync('@loadable/webpack-plugin', this.handleEmit)
Expand Down
20 changes: 0 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250"
integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==

"@babel/helper-plugin-utils@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.8.3.tgz#9ea293be19babc0f52ff8ca88b34c3611b208670"
integrity sha512-j+fq49Xds2smCUNYmEHF9kGNkhbet6yVIBp4e6oeQpH1RUs/Ir06xUKzDjDkGcaaokPiTNs2JBWHjaE4csUkZQ==

"@babel/helper-regex@^7.0.0", "@babel/helper-regex@^7.4.4":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.5.5.tgz#0aa6824f7100a2e0e89c1527c23936c152cab351"
Expand Down Expand Up @@ -305,14 +300,6 @@
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-syntax-dynamic-import" "^7.7.4"

"@babel/plugin-proposal-function-bind@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-function-bind/-/plugin-proposal-function-bind-7.8.3.tgz#e34a1e984771b84b6e5322745edeadca7e500ced"
integrity sha512-6q7VAHJQa9x4P6Lm6h6KHoJUEhx2r1buFKseHICe0ogb1LWxducO4tsQp3hd/7BVBo485YBsn6tJnpuwWm/9cA==
dependencies:
"@babel/helper-plugin-utils" "^7.8.3"
"@babel/plugin-syntax-function-bind" "^7.8.3"

"@babel/plugin-proposal-json-strings@^7.7.4":
version "7.7.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.7.4.tgz#7700a6bfda771d8dc81973249eac416c6b4c697d"
Expand Down Expand Up @@ -366,13 +353,6 @@
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-syntax-function-bind@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-function-bind/-/plugin-syntax-function-bind-7.8.3.tgz#17d722cd8efc9bb9cf8bc59327f2b26295b352f7"
integrity sha512-gEYag4Q3CfqlQcJQQw/KSWdV2husGOnIsOsRlyzkoaNqj2V/V/CSdSJDCGSl67oJ1bdIYP6TjORWPH561dSJpA==
dependencies:
"@babel/helper-plugin-utils" "^7.8.3"

"@babel/plugin-syntax-json-strings@^7.7.4":
version "7.7.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.7.4.tgz#86e63f7d2e22f9e27129ac4e83ea989a382e86cc"
Expand Down