Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (jssStylesArray.length > 0) {
chunks.push({
type: ChunkType.STRING,
name: chunkName,
fileType: FileType.CSS,
content: jssStylesArray.join('\n'),
linkAfter: [],
})
/**
* Setup an import statement for the styles
* The name of the file is either in the meta of the component generator
* or we fallback to the name of the component
*/
const cssFileName = UIDLUtils.getStyleFileName(uidl)
if (declareDependency === 'decorator' && componentDecoratorChunk) {
const decoratorAST = componentDecoratorChunk.content
const decoratorParam = decoratorAST.expression.arguments[0]
ASTUtils.addPropertyToASTObject(decoratorParam, 'styleUrls', [
`${cssFileName}.${FileType.CSS}`,
])
}
if (declareDependency === 'import') {
dependencies.styles = {
// styles will not be used in this case as we have importJustPath flag set
type: 'local',
path: `./${cssFileName}.${FileType.CSS}`,
meta: {
importJustPath: true,
}
})
/**
* If no classes were added, we don't need to import anything or to alter any code
*/
if (!cssClasses.length) {
return structure
}
/**
* Setup an import statement for the styles
* The name of the file is either in the meta of the component generator
* or we fallback to the name of the component
*/
let cssFileName = UIDLUtils.getStyleFileName(uidl)
/**
* In case the moduleExtension flag is passed, the file name should be in the form [fileName].module.css
*/
if (moduleExtension) {
cssFileName = `${cssFileName}.module`
uidl.outputOptions = uidl.outputOptions || {}
uidl.outputOptions.styleFileName = cssFileName
}
dependencies[styleObjectImportName] = {
type: 'local',
path: `./${cssFileName}.${FileType.CSS}`,
}
structure.chunks.push({
}
})
/**
* If no classes were added, we don't need to import anything or to alter any code
*/
if (!cssClasses.length) {
return structure
}
/**
* Setup an import statement for the styles
* The name of the file is either in the meta of the component generator
* or we fallback to the name of the component
*/
let cssFileName = UIDLUtils.getStyleFileName(uidl)
/**
* In case the moduleExtension flag is passed, the file name should be in the form [fileName].module.css
*/
if (moduleExtension) {
cssFileName = `${cssFileName}.module`
uidl.outputOptions = uidl.outputOptions || {}
uidl.outputOptions.styleFileName = cssFileName
}
dependencies[styleObjectImportName] = {
type: 'local',
path: `./${cssFileName}.${FileType.CSS}`,
}
structure.chunks.push({
}
const { chunks, externalDependencies } = await assemblyLine.run(resolvedUIDL, options)
let codeChunks: Record = {}
Object.keys(chunks).forEach((fileType) => {
codeChunks[fileType] = chunksLinker.link(chunks[fileType])
})
processors.forEach((processor) => {
codeChunks = processor(codeChunks)
})
const fileName = UIDLUtils.getComponentFileName(resolvedUIDL)
const styleFileName = UIDLUtils.getStyleFileName(resolvedUIDL)
const templateFileName = UIDLUtils.getTemplateFileName(resolvedUIDL)
const files = fileBundler(codeChunks, fileName, styleFileName, templateFileName)
return {
files,
dependencies: externalDependencies,
}
}