diff --git a/.circleci/config.yml b/.circleci/config.yml
index eb7babba3..df0979e35 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,8 +1,8 @@
# job_environment will setup the environment for any job being executed.
job_environment: &job_environment
- NODE_ENV: test
- WEBPACK_MAX_CORES: 4
- NODE_OPTIONS: --max-old-space-size=8192
+ NODE_ENV: "test"
+ WEBPACK_MAX_CORES: "4"
+ NODE_OPTIONS: "--max-old-space-size=8192"
# job_defaults applies all the defaults for each job.
job_defaults: &job_defaults
@@ -49,7 +49,8 @@ jobs:
- ~/.npm
- persist_to_workspace:
root: .
- paths: node_modules
+ paths:
+ - node_modules
# lint will perform file linting.
lint:
@@ -78,7 +79,7 @@ jobs:
<<: *job_defaults
environment:
<<: *job_environment
- CI: true
+ CI: "true"
JEST_JUNIT_OUTPUT: "reports/junit/js-test-results.xml"
steps:
- checkout
@@ -115,14 +116,15 @@ jobs:
no_output_timeout: 30m
- run:
name: Verify Bundle Size
- command: npx bundlesize
+ command: npx bundlesize2 --enable-github-checks
- save_cache:
key: v1-build-cache-{{ .Branch }}-{{ .Revision }}
paths:
- ./dist
- persist_to_workspace:
root: .
- paths: dist
+ paths:
+ - dist
# docker_tests will test that the docker build process completes.
docker_tests:
diff --git a/package.json b/package.json
index c21f8d350..59225f4a2 100644
--- a/package.json
+++ b/package.json
@@ -420,6 +420,10 @@
{
"path": "./dist/static/assets/js/embed.js",
"maxSize": "15 kB"
+ },
+ {
+ "path": "./dist/static/assets/js/count.js",
+ "maxSize": "2 kB"
}
],
"graphql-schema-linter": {
diff --git a/src/core/client/count/index.ts b/src/core/client/count/index.ts
index e1b6ba00e..ef7cefae0 100644
--- a/src/core/client/count/index.ts
+++ b/src/core/client/count/index.ts
@@ -10,49 +10,89 @@ import injectJSONPCallback from "./injectJSONPCallback";
interface CountQueryArgs {
id?: string;
url?: string;
- notext?: boolean;
+ notext: boolean;
}
/** createCountQueryRef creates a unique reference from the query args */
function createCountQueryRef(args: CountQueryArgs) {
- return btoa(`${JSON.stringify(!!args.notext)};${args.id || args.url}`);
+ return btoa(`${args.notext ? "true" : "false"};${args.id || args.url}`);
+}
+
+interface DetectAndInjectArgs {
+ reset?: boolean;
}
/** Detects count elements and use jsonp to inject the counts. */
-function detectAndInject() {
+function detectAndInject(opts: DetectAndInjectArgs = {}) {
const ORIGIN = getCurrentScriptOrigin(ORIGIN_FALLBACK_ID);
const STORY_URL = resolveStoryURL();
+
/** A map of references pointing to the count query arguments */
const queryMap: Record