-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(storefront): bctheme-1064 Modify Stencil bundle for using Components UI Library #904
Conversation
96094e8
to
c440b56
Compare
@@ -6,6 +6,44 @@ const upath = require('upath'); | |||
|
|||
const partialRegex = /\{\{>\s*([_|\-|a-zA-Z0-9/]+)[^{]*?}}/g; | |||
const dynamicComponentRegex = /\{\{\s*?dynamicComponent\s*(?:'|")([_|\-|a-zA-Z0-9/]+)(?:'|").*?}}/g; | |||
const includeRegex = /{{2}>\s*([_|\-|a-zA-Z0-9/]+)[^{]*?}{2}/g; | |||
const packageMarker = 'external/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's better to consolidate this name with externalTemplatesPath
in stencil-bundle
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We removed externalTemplatesPath
If your comment is still valid please can you add more details:)
const includeRegex = /{{2}>\s*([_|\-|a-zA-Z0-9/]+)[^{]*?}{2}/g; | ||
const packageMarker = 'external/'; | ||
|
||
const isExternalTemplate = (templateName) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add here and below doc types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/stencil-bundle.js
Outdated
console.log('Template Parsing Started...'); | ||
const internalTemplatesList = await recursiveReadDir(this.templatesPath, ['!*.html']); | ||
const searchExternalLib = (content) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind moving searchExternalLib and checkTemplate to class functions (and maybe renaming to make more sense in class domain).
Maybe you can think also about extracting this functionality into separate file, while you are here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/stencil-bundle.js
Outdated
} | ||
let externalLibs; | ||
try { | ||
externalLibs = (await async.map(internalTemplatesList, checkTemplate)).flat(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend not to use async
library, where you can implement it in vanilla js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/stencil-bundle.js
Outdated
}); | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
const checkResult = await async.parallel([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also. I know, that it was in the legacy code, but while you are working on this part, it would really helpful to reduce dependency from async
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
console.log(`${'ok'.green} -- Template Parsing Finished`); | ||
|
||
return ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you try to use return callback(null, ret)
here? What happened?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we received task
object with field templates
undefined
which prevented us to create bundle
lib/stencil-bundle.js
Outdated
); | ||
} | ||
async | ||
.series(this.tasks) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it because you removed the callback invocation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returned parallel function
lib/stencil-bundle.js
Outdated
|
||
return res; | ||
}; | ||
return externalTemplatesImports.map((_import) => _import.split('/')[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason using underscore in _import
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you have any good name suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, that's an old style to declare private class members, while this is not a class and not a member of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np, updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
01f1f0b
to
59af216
Compare
What?
This PR provides functionality of adding templates from external lib to the theme bundle. The main idea is that script can understand is used template consist in the theme or inside external node_modules library.
IMPORTANT
It should be merged only after bctheme-1063
Tickets / Documentation
bctheme-1064
Screenshots (if appropriate)
TBD