@serwist/next 8.4.0 → 8.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +29 -27
- package/dist/index.js +29 -27
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -750,7 +750,7 @@ const prefixedLog = (prefixType, ...message)=>{
|
|
|
750
750
|
if (message.length === 0) {
|
|
751
751
|
console[consoleMethod]("");
|
|
752
752
|
} else {
|
|
753
|
-
console[consoleMethod](
|
|
753
|
+
console[consoleMethod](` ${prefix}`, ...message);
|
|
754
754
|
}
|
|
755
755
|
};
|
|
756
756
|
const info = (...message)=>{
|
|
@@ -774,7 +774,7 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
774
774
|
config = nextConfig.webpack(config, options);
|
|
775
775
|
}
|
|
776
776
|
if (disable) {
|
|
777
|
-
options.isServer && info("
|
|
777
|
+
options.isServer && info("Serwist is disabled.");
|
|
778
778
|
return config;
|
|
779
779
|
}
|
|
780
780
|
if (!config.plugins) {
|
|
@@ -792,39 +792,41 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
792
792
|
}));
|
|
793
793
|
const swEntryJs = path.join(__dirname$1, "sw-entry.js");
|
|
794
794
|
const entry = config.entry;
|
|
795
|
-
config.entry = ()=>
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
]
|
|
804
|
-
|
|
795
|
+
config.entry = async ()=>{
|
|
796
|
+
const entries = await entry();
|
|
797
|
+
if (entries["main.js"] && !entries["main.js"].includes(swEntryJs)) {
|
|
798
|
+
if (Array.isArray(entries["main.js"])) {
|
|
799
|
+
entries["main.js"].unshift(swEntryJs);
|
|
800
|
+
} else if (typeof entries["main.js"] === "string") {
|
|
801
|
+
entries["main.js"] = [
|
|
802
|
+
swEntryJs,
|
|
803
|
+
entries["main.js"]
|
|
804
|
+
];
|
|
805
805
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
]
|
|
814
|
-
|
|
806
|
+
}
|
|
807
|
+
if (entries["main-app"] && !entries["main-app"].includes(swEntryJs)) {
|
|
808
|
+
if (Array.isArray(entries["main-app"])) {
|
|
809
|
+
entries["main-app"].unshift(swEntryJs);
|
|
810
|
+
} else if (typeof entries["main-app"] === "string") {
|
|
811
|
+
entries["main-app"] = [
|
|
812
|
+
swEntryJs,
|
|
813
|
+
entries["main-app"]
|
|
814
|
+
];
|
|
815
815
|
}
|
|
816
|
-
|
|
817
|
-
|
|
816
|
+
}
|
|
817
|
+
return entries;
|
|
818
|
+
};
|
|
818
819
|
if (!options.isServer) {
|
|
819
820
|
if (!register) {
|
|
820
821
|
info("Service worker won't be automatically registered as per the config, please call the following code in componentDidMount or useEffect:");
|
|
821
|
-
info(
|
|
822
|
+
info(" window.serwist.register()");
|
|
822
823
|
if (!tsConfigJson?.compilerOptions?.types?.includes("@serwist/next/typings")) {
|
|
823
824
|
info("You may also want to add @serwist/next/typings to compilerOptions.types in your tsconfig.json/jsconfig.json.");
|
|
824
825
|
}
|
|
825
826
|
}
|
|
826
827
|
const { swSrc: providedSwSrc, swDest: providedSwDest, additionalPrecacheEntries, exclude = [], modifyURLPrefix = {}, manifestTransforms = [], ...otherBuildOptions } = buildOptions;
|
|
827
|
-
let swSrc = providedSwSrc
|
|
828
|
+
let swSrc = providedSwSrc;
|
|
829
|
+
let swDest = providedSwDest;
|
|
828
830
|
if (!path.isAbsolute(swSrc)) {
|
|
829
831
|
swSrc = path.join(options.dir, swSrc);
|
|
830
832
|
}
|
|
@@ -835,7 +837,7 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
835
837
|
const shouldBuildSWEntryWorker = cacheOnFrontEndNav;
|
|
836
838
|
let swEntryPublicPath = undefined;
|
|
837
839
|
if (shouldBuildSWEntryWorker) {
|
|
838
|
-
const swEntryWorkerSrc = path.join(__dirname$1,
|
|
840
|
+
const swEntryWorkerSrc = path.join(__dirname$1, "sw-entry-worker.js");
|
|
839
841
|
const swEntryName = `swe-worker-${getContentHash(swEntryWorkerSrc, dev)}.js`;
|
|
840
842
|
swEntryPublicPath = path.posix.join(basePath, swEntryName);
|
|
841
843
|
const swEntryWorkerDest = path.join(destDir, swEntryName);
|
|
@@ -858,7 +860,7 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
858
860
|
]
|
|
859
861
|
}));
|
|
860
862
|
// Precache files in public folder
|
|
861
|
-
let resolvedManifestEntries = additionalPrecacheEntries
|
|
863
|
+
let resolvedManifestEntries = additionalPrecacheEntries;
|
|
862
864
|
if (!resolvedManifestEntries) {
|
|
863
865
|
const swDestFileName = path.basename(swDest);
|
|
864
866
|
resolvedManifestEntries = fg.sync([
|
package/dist/index.js
CHANGED
|
@@ -745,7 +745,7 @@ const prefixedLog = (prefixType, ...message)=>{
|
|
|
745
745
|
if (message.length === 0) {
|
|
746
746
|
console[consoleMethod]("");
|
|
747
747
|
} else {
|
|
748
|
-
console[consoleMethod](
|
|
748
|
+
console[consoleMethod](` ${prefix}`, ...message);
|
|
749
749
|
}
|
|
750
750
|
};
|
|
751
751
|
const info = (...message)=>{
|
|
@@ -769,7 +769,7 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
769
769
|
config = nextConfig.webpack(config, options);
|
|
770
770
|
}
|
|
771
771
|
if (disable) {
|
|
772
|
-
options.isServer && info("
|
|
772
|
+
options.isServer && info("Serwist is disabled.");
|
|
773
773
|
return config;
|
|
774
774
|
}
|
|
775
775
|
if (!config.plugins) {
|
|
@@ -787,39 +787,41 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
787
787
|
}));
|
|
788
788
|
const swEntryJs = path.join(__dirname, "sw-entry.js");
|
|
789
789
|
const entry = config.entry;
|
|
790
|
-
config.entry = ()=>
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
]
|
|
799
|
-
|
|
790
|
+
config.entry = async ()=>{
|
|
791
|
+
const entries = await entry();
|
|
792
|
+
if (entries["main.js"] && !entries["main.js"].includes(swEntryJs)) {
|
|
793
|
+
if (Array.isArray(entries["main.js"])) {
|
|
794
|
+
entries["main.js"].unshift(swEntryJs);
|
|
795
|
+
} else if (typeof entries["main.js"] === "string") {
|
|
796
|
+
entries["main.js"] = [
|
|
797
|
+
swEntryJs,
|
|
798
|
+
entries["main.js"]
|
|
799
|
+
];
|
|
800
800
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
]
|
|
809
|
-
|
|
801
|
+
}
|
|
802
|
+
if (entries["main-app"] && !entries["main-app"].includes(swEntryJs)) {
|
|
803
|
+
if (Array.isArray(entries["main-app"])) {
|
|
804
|
+
entries["main-app"].unshift(swEntryJs);
|
|
805
|
+
} else if (typeof entries["main-app"] === "string") {
|
|
806
|
+
entries["main-app"] = [
|
|
807
|
+
swEntryJs,
|
|
808
|
+
entries["main-app"]
|
|
809
|
+
];
|
|
810
810
|
}
|
|
811
|
-
|
|
812
|
-
|
|
811
|
+
}
|
|
812
|
+
return entries;
|
|
813
|
+
};
|
|
813
814
|
if (!options.isServer) {
|
|
814
815
|
if (!register) {
|
|
815
816
|
info("Service worker won't be automatically registered as per the config, please call the following code in componentDidMount or useEffect:");
|
|
816
|
-
info(
|
|
817
|
+
info(" window.serwist.register()");
|
|
817
818
|
if (!tsConfigJson?.compilerOptions?.types?.includes("@serwist/next/typings")) {
|
|
818
819
|
info("You may also want to add @serwist/next/typings to compilerOptions.types in your tsconfig.json/jsconfig.json.");
|
|
819
820
|
}
|
|
820
821
|
}
|
|
821
822
|
const { swSrc: providedSwSrc, swDest: providedSwDest, additionalPrecacheEntries, exclude = [], modifyURLPrefix = {}, manifestTransforms = [], ...otherBuildOptions } = buildOptions;
|
|
822
|
-
let swSrc = providedSwSrc
|
|
823
|
+
let swSrc = providedSwSrc;
|
|
824
|
+
let swDest = providedSwDest;
|
|
823
825
|
if (!path.isAbsolute(swSrc)) {
|
|
824
826
|
swSrc = path.join(options.dir, swSrc);
|
|
825
827
|
}
|
|
@@ -830,7 +832,7 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
830
832
|
const shouldBuildSWEntryWorker = cacheOnFrontEndNav;
|
|
831
833
|
let swEntryPublicPath = undefined;
|
|
832
834
|
if (shouldBuildSWEntryWorker) {
|
|
833
|
-
const swEntryWorkerSrc = path.join(__dirname,
|
|
835
|
+
const swEntryWorkerSrc = path.join(__dirname, "sw-entry-worker.js");
|
|
834
836
|
const swEntryName = `swe-worker-${getContentHash(swEntryWorkerSrc, dev)}.js`;
|
|
835
837
|
swEntryPublicPath = path.posix.join(basePath, swEntryName);
|
|
836
838
|
const swEntryWorkerDest = path.join(destDir, swEntryName);
|
|
@@ -853,7 +855,7 @@ const withPWAInit = (pluginOptions)=>{
|
|
|
853
855
|
]
|
|
854
856
|
}));
|
|
855
857
|
// Precache files in public folder
|
|
856
|
-
let resolvedManifestEntries = additionalPrecacheEntries
|
|
858
|
+
let resolvedManifestEntries = additionalPrecacheEntries;
|
|
857
859
|
if (!resolvedManifestEntries) {
|
|
858
860
|
const swDestFileName = path.basename(swDest);
|
|
859
861
|
resolvedManifestEntries = fg.sync([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/next",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A module that integrates Serwist into your Next.js application.",
|
|
6
6
|
"files": [
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"clean-webpack-plugin": "4.0.0",
|
|
69
69
|
"fast-glob": "3.3.2",
|
|
70
|
-
"@serwist/build": "8.4.
|
|
71
|
-
"@serwist/webpack-plugin": "8.4.
|
|
72
|
-
"@serwist/window": "8.4.
|
|
70
|
+
"@serwist/build": "8.4.2",
|
|
71
|
+
"@serwist/webpack-plugin": "8.4.2",
|
|
72
|
+
"@serwist/window": "8.4.2"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/node": "20.10.5",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"type-fest": "4.8.3",
|
|
82
82
|
"typescript": "5.4.0-dev.20231226",
|
|
83
83
|
"webpack": "5.89.0",
|
|
84
|
-
"@serwist/constants": "8.4.
|
|
84
|
+
"@serwist/constants": "8.4.2"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"next": ">=14.0.0",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"scripts": {
|
|
91
91
|
"build": "rimraf dist && cross-env NODE_ENV=production rollup --config rollup.config.js",
|
|
92
92
|
"dev": "rollup --config rollup.config.js --watch",
|
|
93
|
-
"lint": "
|
|
93
|
+
"lint": "biome lint ./src",
|
|
94
94
|
"typecheck": "tsc"
|
|
95
95
|
}
|
|
96
96
|
}
|