File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 16
16
" hydrate/"
17
17
],
18
18
"scripts" : {
19
- "build" : " npm run util:copy-icons && stencil build" ,
19
+ "build" : " npm run util:copy-icons && stencil build && npm run util:patch-es5-helpers " ,
20
20
"build:watch" : " npm run util:copy-icons && stencil build --watch" ,
21
21
"build:watch-dev" : " npm run util:copy-icons && stencil build --dev --watch" ,
22
22
"build-storybook" : " npm run util:copy-icons && stencil build --config stencil.config.ts && build-storybook --static-dir ./www --output-dir ./docs" ,
48
48
"util:copy-icons" : " cpy \" ./node_modules/@esri/calcite-ui-icons/js/*.json\" \" ./src/components/icon/assets/icon/\" --flat" ,
49
49
"util:deploy-next" : " npm run util:prep-next && npm run util:push-tags && npm run util:publish-next" ,
50
50
"util:deploy-next-from-ci" : " ts-node --project ./tsconfig-node-scripts.json support/deployNextFromCI.ts" ,
51
+ "util:patch-es5-helpers" : " ts-node support/patchES5Helpers.ts" ,
51
52
"util:prep-next" : " ts-node --project ./tsconfig-node-scripts.json support/prepReleaseCommit.ts --next && npm run build" ,
52
53
"util:publish-next" : " npm publish --tag next" ,
53
54
"util:check-squash-mergeable-branch" : " ts-node --project ./tsconfig-node-scripts.json support/checkSquashMergeableBranch.ts" ,
Original file line number Diff line number Diff line change
1
+ const {
2
+ promises : { readFile, readdir, writeFile }
3
+ } = require ( "fs" ) ;
4
+ const { normalize } = require ( "path" ) ;
5
+ const { quote } = require ( "shell-quote" ) ;
6
+
7
+ ( async function ( ) {
8
+ const esmEs5Output = quote ( [ normalize ( `${ __dirname } /../dist/esm-es5/` ) ] ) ;
9
+
10
+ // we patch __spreadArray to work around https://github.com/microsoft/tslib/issues/175
11
+ // see https://github.com/Esri/calcite-components/issues/4481#issuecomment-1128336510 for more info
12
+ const spreadArrayHelperToken =
13
+ / ( v a r _ _ s p r e a d A r r a y \= t h i s \& \& t h i s \. _ _ s p r e a d A r r a y \| \| f u n c t i o n \( \w \, ) ( \w ) ( \, \w \) \{ ) ( i f \( (?: \w ) \| \| a r g u m e n t s \. l e n g t h \= \= \= 2 \) ) / ;
14
+ const patchedSpreadArrayReplacement = '$1$2$3if(typeof $2 === "string"){$2=Array.prototype.slice.call($2)}$4' ;
15
+ const files = await readdir ( esmEs5Output ) ;
16
+
17
+ try {
18
+ for ( const file of files ) {
19
+ const filePath = quote ( [ normalize ( `${ esmEs5Output } /${ file } ` ) ] ) ;
20
+ const contents = await readFile ( filePath , { encoding : "utf8" } ) ;
21
+ await writeFile ( filePath , contents . replace ( spreadArrayHelperToken , patchedSpreadArrayReplacement ) ) ;
22
+ }
23
+ } catch ( err ) {
24
+ console . error ( err ) ;
25
+ process . exit ( 1 ) ;
26
+ }
27
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments