Skip to content

Commit

Permalink
fix(rn): 2.1.x在编译同名sass文件时会产生报错 close #5945
Browse files Browse the repository at this point in the history
  • Loading branch information
Pines-Cheng committed Apr 26, 2020
1 parent 9e2b894 commit 3a9762e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/taro-rn-runner/src/loaders/JSXToStylesSheetLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function ${GET_STYLE_FUNC_NAME}(classNameExpression) {
styleNames.push(specifiers[0].local.name)
} else {
// 不论 styleName 是第几个,最后都会被合成一个
const styleIdentifierName = _.camelCase(sourceValue)
const styleIdentifierName = _.camelCase(sourceValue) + styleNameSet.length
styleNameSet.push(styleIdentifierName)
node.specifiers = [
t.importDefaultSpecifier(
Expand All @@ -296,9 +296,7 @@ function ${GET_STYLE_FUNC_NAME}(classNameExpression) {
const styleSheetIdentifierValue = `${cssFileBaseName.replace(/[-.]/g, '_') + NAME_SUFFIX}`
const styleSheetIdentifierPath = `./index_styles`
const styleSheetIdentifier = t.identifier(styleSheetIdentifierValue)

// node.specifiers = [t.importDefaultSpecifier(styleSheetIdentifier)]
// node.source = t.stringLiteral(styleSheetIdentifierPath)
// const indexStyleSheet = __non_webpack_require__('./index_styles').default
const webpackNode = template(
`const ${styleSheetIdentifierValue} =__non_webpack_require__('${styleSheetIdentifierPath}').default`,
babylonConfig as any
Expand All @@ -319,7 +317,7 @@ function ${GET_STYLE_FUNC_NAME}(classNameExpression) {
})
// this.callback(null, source, ast)
const code = generate(ast).code
// if (filePath.includes('pages/cart/cart.js')) console.log('JSXToStylesSheetLoader', code)
// if (filePath.includes('pages/index/index.js')) console.log('JSXToStylesSheetLoader', code)
return code
} catch (e) {
this.emitError(e)
Expand Down

0 comments on commit 3a9762e

Please sign in to comment.