Skip to content

Commit

Permalink
passing tests for wb wpp
Browse files Browse the repository at this point in the history
  • Loading branch information
tropicadri committed Jan 3, 2022
1 parent 3ded4ab commit 39d313b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/workbox-webpack-plugin/src/generate-sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,4 @@ class GenerateSW {
}
}

export {GenerateSW}
export {GenerateSW};
19 changes: 12 additions & 7 deletions packages/workbox-webpack-plugin/src/inject-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ class InjectManifest {

const childCompiler = compilation.createChildCompiler(
this.constructor.name,
outputOptions, [],
outputOptions,
[],
);

childCompiler.context = parentCompiler.context;
Expand Down Expand Up @@ -260,7 +261,9 @@ class InjectManifest {
parentCompiler: webpack.Compiler,
): void {
// eslint-disable-next-line
const source = (parentCompiler.inputFileSystem as any).readFileSync(this.config.swSrc)
const source = (parentCompiler.inputFileSystem as any).readFileSync(
this.config.swSrc,
);
compilation.emitAsset(this.config.swDest!, new RawSource(source));
}

Expand All @@ -278,7 +281,7 @@ class InjectManifest {
this.config = validateWebpackInjectManifestOptions(this.config);
} catch (error) {
// eslint-disable-next-line
if(error instanceof Error){
if (error instanceof Error) {
throw new Error(
`Please check your ${this.constructor.name} plugin ` +
// eslint-disable-next-line
Expand Down Expand Up @@ -331,7 +334,9 @@ class InjectManifest {
warning instanceof Error && warning.message === warningMessage,
)
) {
compilation.warnings.push(new Error(warningMessage) as webpack.WebpackError);
compilation.warnings.push(
new Error(warningMessage) as webpack.WebpackError,
);
}
} else {
this.alreadyCalled = true;
Expand All @@ -341,7 +346,7 @@ class InjectManifest {

// Ensure that we don't precache any of the assets generated by *any*
// instance of this plugin.
config.exclude!.push((name:string) => _generatedAssetNames.has(name));
config.exclude!.push((name: string) => _generatedAssetNames.has(name));

// See https://webpack.js.org/contribute/plugin-patterns/#monitoring-the-watch-graph
const absoluteSwSrc = upath.resolve(this.config.swSrc);
Expand All @@ -362,7 +367,7 @@ class InjectManifest {
throw new Error(
`Multiple instances of ${config.injectionPoint ?? ''} were ` +
`found in your SW source. Include it only once. For more info, see ` +
`https://github.com/GoogleChrome/workbox/issues/2681`,
`https://github.com/GoogleChrome/workbox/issues/2681`,
);
}

Expand Down Expand Up @@ -427,4 +432,4 @@ class InjectManifest {
}
}

export {InjectManifest}
export {InjectManifest};
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function checkConditions(
): boolean {
for (const condition of conditions) {
if (typeof condition === 'function') {
return condition(asset.name)
return condition(asset.name);
} else {
if (ModuleFilenameHelpers.matchPart(asset.name, condition)) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ import type {Compilation} from 'webpack';
*
* @private
*/
export function getSourcemapAssetName(compilation: Compilation, swContents: string, swDest: string): string | undefined {
export function getSourcemapAssetName(
compilation: Compilation,
swContents: string,
swDest: string,
): string | undefined {
// eslint-disable-next-line
const url = sourceMapURL.getFrom(swContents);
if (url) {
Expand All @@ -39,7 +43,8 @@ export function getSourcemapAssetName(compilation: Compilation, swContents: stri
// See https://github.com/GoogleChrome/workbox/issues/2250
const swAssetDirname = upath.dirname(swDest);
const sourcemapURLAssetName = upath.normalize(
upath.join(swAssetDirname, url));
upath.join(swAssetDirname, url),
);

// Not sure if there's a better way to check for asset existence?
if (compilation.getAsset(sourcemapURLAssetName)) {
Expand Down
22 changes: 9 additions & 13 deletions packages/workbox-webpack-plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"esModuleInterop": true,
"module": "CommonJS",
"outDir": "./build",
"resolveJsonModule": true,
"rootDir": "./src",
"target": "ES2018",
"tsBuildInfoFile": "./tsconfig.tsbuildinfo"
"esModuleInterop": true,
"module": "CommonJS",
"outDir": "./build",
"resolveJsonModule": true,
"rootDir": "./src",
"target": "ES2018",
"tsBuildInfoFile": "./tsconfig.tsbuildinfo"
},
"include": [
"src/**/*.ts"
],
"references": [
{"path": "../workbox-build/"}
]
"include": ["src/**/*.ts"],
"references": [{"path": "../workbox-build/"}]
}

0 comments on commit 39d313b

Please sign in to comment.