Skip to content

Commit

Permalink
chore: add patch from #587
Browse files Browse the repository at this point in the history
  • Loading branch information
daine committed Jul 24, 2024
1 parent 173dfc2 commit 9827d93
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 29 deletions.
1 change: 0 additions & 1 deletion .github/workflows/compile-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ jobs:
with:
token: ${{ secrets.NPM_TOKEN }}
package: ${{ matrix.dist }}
dry-run: true
tag: canary

- name: Report deployment to Sentinel
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"scripts": {
"ng": "ng",
"compile": "gulp compile",
"prebuild": "npm run patch:stenciljs",
"build": "npx lerna run build --concurrency=1",
"pretest": "npm run patch:stenciljs",
"test": "npx lerna run test",
Expand Down
53 changes: 44 additions & 9 deletions packages/react-ssr/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,47 @@ const createReactWrapperModules = async ({ entryPoints, distRoot }) => {
console.info('writing modules completed!');
};

createReactWrapperModules({
entryPoints: readdirSync(COMPONENTS_DIR)
.filter((file) => file.startsWith('gcds') && file.endsWith('.js') && !file.endsWith('2.js'))
.map((file) => join(COMPONENTS_DIR, file)),
distRoot: join(DIST_DIR),
}).catch((err) => {
console.error('unexpected error generating module!', err);
exit(1);
});
// Copy over the required stencil files, add required patch and modify imports in component files
const patchStencil = async () => {

// Updating stencil import in component files
const componentOptions = {
files: './dist/esm/components/*.js',
from: '@stencil/core/internal/client',
to: '../lib/stencil',
};

await replaceInFile(componentOptions);

// Patching stencil
// Will need to check if the from property needs to be updated when we update @stencil/core
const stencilOptions = {
files: './dist/esm/lib/stencil/index.js',
from: "const win = typeof window !== 'undefined' ? window : {};",
to: "const win = typeof window !== 'undefined' ? window : globalThis || {};",
};

try {
const results = await replaceInFile(stencilOptions);

if (results[0].hasChanged) {
createReactWrapperModules({
entryPoints: readdirSync(COMPONENTS_DIR)
.filter((file) => file.startsWith('gcds') && file.endsWith('.js') && !file.endsWith('2.js'))
.map((file) => join(COMPONENTS_DIR, file)),
distRoot: join(DIST_DIR),
}).catch((err) => {
console.error('unexpected error generating module!', err);
exit(1);
});
} else {
throw new Error('Unable to patch Stencil');
}
}
catch(error) {
throw new Error(error)
}

};

patchStencil();
21 changes: 4 additions & 17 deletions patches/@stencil+core+4.11.0.patch
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
diff --git a/node_modules/@stencil/core/internal/client/index.js b/node_modules/@stencil/core/internal/client/index.js
index 767b59b..3a861af 100644
--- a/node_modules/@stencil/core/internal/client/index.js
+++ b/node_modules/@stencil/core/internal/client/index.js
@@ -3987,7 +3987,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
};
const styles = /*@__PURE__*/ new Map();
const modeResolutionChain = [];
-const win = typeof window !== 'undefined' ? window : {};
+const win = typeof window !== 'undefined' ? window : globalThis || {};
const doc = win.document || { head: {} };
const H = (win.HTMLElement || class {
});
diff --git a/node_modules/@stencil/core/mock-doc/index.cjs b/node_modules/@stencil/core/mock-doc/index.cjs
index 13b322c..e0ed9ac 100644
index 13b322c..e4ee0cf 100644
--- a/node_modules/@stencil/core/mock-doc/index.cjs
+++ b/node_modules/@stencil/core/mock-doc/index.cjs
@@ -3304,12 +3304,7 @@ class MockNodeList {
Expand All @@ -25,12 +12,12 @@ index 13b322c..e0ed9ac 100644
-Testing components with ElementInternals is fully supported in e2e tests.`);
- },
- });
+ return { setFormValue: (value) => {}};
+ return { setFormValue: (value) => {} };
}
constructor(ownerDocument, nodeName, namespaceURI = null) {
super(ownerDocument, 1 /* NODE_TYPES.ELEMENT_NODE */, typeof nodeName === 'string' ? nodeName : null, null);
diff --git a/node_modules/@stencil/core/mock-doc/index.js b/node_modules/@stencil/core/mock-doc/index.js
index a061891..d9bd7e1 100644
index a061891..0841534 100644
--- a/node_modules/@stencil/core/mock-doc/index.js
+++ b/node_modules/@stencil/core/mock-doc/index.js
@@ -3301,12 +3301,7 @@ class MockNodeList {
Expand All @@ -43,7 +30,7 @@ index a061891..d9bd7e1 100644
-Testing components with ElementInternals is fully supported in e2e tests.`);
- },
- });
+ return { setFormValue: (value) => {}};
+ return { setFormValue: (value) => {} };
}
constructor(ownerDocument, nodeName, namespaceURI = null) {
super(ownerDocument, 1 /* NODE_TYPES.ELEMENT_NODE */, typeof nodeName === 'string' ? nodeName : null, null);

0 comments on commit 9827d93

Please sign in to comment.