Skip to content
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

used a simpler hashing strategy when a file system is available #498

Merged
merged 2 commits into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/babel-plugin-emotion/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,17 @@ function buildTargetObjectProperty(path, state, t) {
filename === rootPath ? basename(filename) : filename.slice(rootPath.length)

const positionInFile = state.count++

const stuffToHash = [moduleName]

if (finalPath) {
stuffToHash.push(normalize(finalPath))
} else {
stuffToHash.push(state.file.code)
}

const stableClassName = getName(
`${hashArray([
normalize(finalPath),
moduleName,
state.file.code
])}${positionInFile}`,
`${hashArray(stuffToHash)}${positionInFile}`,
'css'
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ exports[`styled macro babel 6 tagged template literal function 1`] = `
"import _styled from './styled';

const SomeComponent = /*#__PURE__*/_styled('div', {
target: 'css-gx73fp0'
target: 'css-o9rakq0'
})('display:flex;');"
`;

exports[`styled macro babel 6 tagged template literal member 1`] = `
"import _styled from './styled';

const SomeComponent = /*#__PURE__*/_styled('div', {
target: 'css-5a9af00'
target: 'css-o9rakq0'
})('display:flex;');"
`;

Expand Down Expand Up @@ -232,7 +232,7 @@ exports[`styled macro babel 7 tagged template literal function 1`] = `
const SomeComponent =
/*#__PURE__*/
_styled('div', {
target: \\"css-gx73fp0\\"
target: \\"css-o9rakq0\\"
})(\\"display:flex;\\");"
`;

Expand All @@ -242,6 +242,6 @@ exports[`styled macro babel 7 tagged template literal member 1`] = `
const SomeComponent =
/*#__PURE__*/
_styled(\\"div\\", {
target: \\"css-5a9af00\\"
target: \\"css-o9rakq0\\"
})(\\"display:flex;\\");"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ exports[`source map babel 6 styled object styles source map 1`] = `

exports[`source map babel 6 styled source map 1`] = `
"const Avatar = /*#__PURE__*/styled('img', {
target: 'css-1xslkpx0'
target: 'css-1367ks30'
})('width:96px;height:96px;border-radius:', props => props.theme.borderRadius, ';border:1px solid ', props => props.theme.borderColor, ';/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlZC5zb3VyY2UtbWFwLnRlc3QuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQTRCIiwiZmlsZSI6InN0eWxlZC5zb3VyY2UtbWFwLnRlc3QuanMiLCJzb3VyY2VzQ29udGVudCI6WyJjb25zdCBBdmF0YXIgPSBzdHlsZWQoJ2ltZycpYFxuICAgICAgICB3aWR0aDogOTZweDtcbiAgICAgICAgaGVpZ2h0OiA5NnB4O1xuXG4gICAgICAgIGJvcmRlci1yYWRpdXM6ICR7cHJvcHMgPT5cbiAgICAgICAgICBwcm9wcy50aGVtZS5ib3JkZXJSYWRpdXN9O1xuXG4gICAgICAgIGJvcmRlcjogMXB4IHNvbGlkICR7cHJvcHMgPT5cbiAgICAgICAgICBwcm9wcy50aGVtZS5ib3JkZXJDb2xvcn07XG4gICAgICBgIl19 */');"
`;

Expand Down Expand Up @@ -124,6 +124,6 @@ exports[`source map babel 7 styled source map 1`] = `
"const Avatar =
/*#__PURE__*/
styled('img', {
target: \\"css-1xslkpx0\\"
target: \\"css-1367ks30\\"
})(\\"width:96px;height:96px;border-radius:\\", props => props.theme.borderRadius, \\";border:1px solid \\", props => props.theme.borderColor, \\";/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlZC5zb3VyY2UtbWFwLnRlc3QuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQTRCIiwiZmlsZSI6InN0eWxlZC5zb3VyY2UtbWFwLnRlc3QuanMiLCJzb3VyY2VzQ29udGVudCI6WyJjb25zdCBBdmF0YXIgPSBzdHlsZWQoJ2ltZycpYFxuICAgICAgICB3aWR0aDogOTZweDtcbiAgICAgICAgaGVpZ2h0OiA5NnB4O1xuXG4gICAgICAgIGJvcmRlci1yYWRpdXM6ICR7cHJvcHMgPT5cbiAgICAgICAgICBwcm9wcy50aGVtZS5ib3JkZXJSYWRpdXN9O1xuXG4gICAgICAgIGJvcmRlcjogMXB4IHNvbGlkICR7cHJvcHMgPT5cbiAgICAgICAgICBwcm9wcy50aGVtZS5ib3JkZXJDb2xvcn07XG4gICAgICBgIl19 */\\");"
`;
Loading