UNPKG

sdin

Version:

JavaScript package builder.

2 lines 2.38 kB
Object.defineProperty(exports,"__esModule",{value:!0}),exports.createStyleModuleTypescriptTransformer=e;var c=require("typescript");let y=/\.(css|sass|scss)$/;function e(){return r=>{let t=e=>(0,c.isImportDeclaration)(e)?a(e,r):(0,c.isExportDeclaration)(e)?o(e,r):(0,c.visitEachChild)(e,t,r);return{transformBundle:e=>e,transformSourceFile:e=>(0,c.visitEachChild)(e,t,r)}}}function a(e,r){var t=e.moduleSpecifier,a=e.importClause;return(0,c.isStringLiteral)(t)&&y.test(t.text)?(t=r.factory,a&&a.name?(r=t.createVariableDeclaration(a.name,void 0,t.createTypeReferenceNode("Record",[t.createKeywordTypeNode(c.SyntaxKind.StringKeyword),t.createUnionTypeNode([t.createKeywordTypeNode(c.SyntaxKind.StringKeyword),t.createKeywordTypeNode(c.SyntaxKind.UndefinedKeyword)])])),t.createVariableStatement([t.createModifier(c.SyntaxKind.DeclareKeyword)],t.createVariableDeclarationList([r],c.NodeFlags.Const))):[]):e}function o(e,r){var t=e.moduleSpecifier,a=e.exportClause;if(!t||!(0,c.isStringLiteral)(t)||!y.test(t.text))return e;var o=r.factory;if(a&&(0,c.isNamespaceExport)(a)&&a.name)return t=o.createVariableDeclaration(a.name,void 0,o.createTypeReferenceNode("Record",[o.createKeywordTypeNode(c.SyntaxKind.StringKeyword),o.createUnionTypeNode([o.createKeywordTypeNode(c.SyntaxKind.StringKeyword),o.createKeywordTypeNode(c.SyntaxKind.UndefinedKeyword)])])),o.createVariableStatement([o.createModifier(c.SyntaxKind.ExportKeyword),o.createModifier(c.SyntaxKind.DeclareKeyword)],o.createVariableDeclarationList([t],c.NodeFlags.Const));if(a&&(0,c.isNamedExports)(a)&&0<a.elements.length){var n,i,d=[];for(n of a.elements)"default"===(null==(i=n.propertyName)?void 0:i.escapedText)?d.push(o.createVariableDeclaration(n.name,void 0,o.createTypeReferenceNode("Record",[o.createKeywordTypeNode(c.SyntaxKind.StringKeyword),o.createUnionTypeNode([o.createKeywordTypeNode(c.SyntaxKind.StringKeyword),o.createKeywordTypeNode(c.SyntaxKind.UndefinedKeyword)])]))):d.push(o.createVariableDeclaration(n.name,void 0,o.createUnionTypeNode([o.createKeywordTypeNode(c.SyntaxKind.StringKeyword),o.createKeywordTypeNode(c.SyntaxKind.UndefinedKeyword)])));return o.createVariableStatement([o.createModifier(c.SyntaxKind.ExportKeyword),o.createModifier(c.SyntaxKind.DeclareKeyword)],o.createVariableDeclarationList(d,c.NodeFlags.Const))}return[]} //# sourceMappingURL=typescript-transformer-style-module.js.map