Skip to content

Commit

Permalink
format files
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Dec 12, 2021
1 parent 45f2d91 commit 56ef256
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions examples/server-side-rendering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ git clone https://github.com/gregberge/loadable-components.git

2. Install [https://yarnpkg.com/lang/en/docs/install](yarn) if haven't already
3. Install libary dependencies and build library

```bash
yarn
yarn build
Expand All @@ -20,6 +21,7 @@ yarn build
```bash
cd ./loadable-components/examples/server-side-rendering
```

5. Install project dependencies

```bash
Expand Down
3 changes: 1 addition & 2 deletions packages/component/src/createLoadable.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ const withChunkExtractor = Component => {
</Context.Consumer>
)
if (Component.displayName) {
LoadableWithChunkExtractor.displayName =
`${Component.displayName}WithChunkExtractor`;
LoadableWithChunkExtractor.displayName = `${Component.displayName}WithChunkExtractor`
}
return LoadableWithChunkExtractor
}
Expand Down
4 changes: 3 additions & 1 deletion packages/server/src/ChunkExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ class ChunkExtractor {
const resolvedFilename =
typeof filename === 'object' && filename.name ? filename.name : filename
const resolvedIntegrity =
typeof filename === 'object' && filename.integrity ? filename.integrity : null
typeof filename === 'object' && filename.integrity
? filename.integrity
: null

return {
filename: resolvedFilename,
Expand Down
5 changes: 4 additions & 1 deletion packages/server/src/ChunkExtractor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ describe('ChunkExtrator', () => {
assets: stats.namedChunkGroups.main.assets.map(name => ({
name,
// pseudo hash - reversed name
integrity: name.split('').reverse().join(''),
integrity: name
.split('')
.reverse()
.join(''),
})),
},
},
Expand Down
7 changes: 5 additions & 2 deletions packages/server/src/util.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Use __non_webpack_require__ to prevent Webpack from compiling it
// when the server-side code is compiled with Webpack
// eslint-disable-next-line camelcase, no-undef, global-require, import/no-dynamic-require, no-eval
const getRequire = () => typeof __non_webpack_require__ !== 'undefined' ? __non_webpack_require__ : eval('require');
const getRequire = () =>
typeof __non_webpack_require__ !== 'undefined'
? __non_webpack_require__
: eval('require')

export const clearModuleCache = moduleName => {
const { cache } = getRequire();
const { cache } = getRequire()
const m = cache[moduleName]
if (m) {
// remove self from own parents
Expand Down
8 changes: 4 additions & 4 deletions packages/webpack-plugin/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LoadablePlugin {
stats.generator = 'loadable-components'

// we don't need all chunk information, only a type
stats.chunks = [...compilation.chunks].map((chunk) => {
stats.chunks = [...compilation.chunks].map(chunk => {
return {
id: chunk.id,
files: [...chunk.files],
Expand All @@ -46,7 +46,8 @@ class LoadablePlugin {
Object.values(stats.namedChunkGroups).forEach(namedChunkGroup => {
namedChunkGroup.assets.forEach(namedChunkGroupAsset => {
if (!namedChunkGroupAsset.integrity) {
const asset = stats.assets.find(a => a.name === namedChunkGroupAsset.name) || {}
const asset =
stats.assets.find(a => a.name === namedChunkGroupAsset.name) || {}
if (asset.integrity) {
namedChunkGroupAsset.integrity = asset.integrity
}
Expand Down Expand Up @@ -124,8 +125,7 @@ class LoadablePlugin {
compilation.hooks.processAssets.tap(
{
name,
stage:
compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT,
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT,
},
() => {
const asset = this.handleEmit(compilation)
Expand Down

0 comments on commit 56ef256

Please sign in to comment.