From b947efd437504cc1fad7cbd296052277c25fc203 Mon Sep 17 00:00:00 2001 From: Jayden Seric Date: Tue, 12 May 2020 18:15:50 +1000 Subject: [PATCH 1/2] Support Node.js ESM. Fixes https://github.com/zeit/styled-jsx/issues/640 . --- css.js | 24 ++------- css.mjs | 5 ++ readme.md | 2 +- src/_utils.js | 2 +- src/babel-external.js | 9 ++-- src/decoys.js | 19 +++++++ test/babel6/snapshots/attribute.js.md | 4 +- test/babel6/snapshots/attribute.js.snap | Bin 1530 -> 1532 bytes test/babel6/snapshots/external.js.md | 14 ++--- test/babel6/snapshots/external.js.snap | Bin 1502 -> 1501 bytes test/babel6/snapshots/index.js.md | 28 +++++----- test/babel6/snapshots/index.js.snap | Bin 2489 -> 2491 bytes test/babel6/snapshots/macro.js.md | 6 +-- test/babel6/snapshots/macro.js.snap | Bin 540 -> 543 bytes test/babel6/snapshots/plugins.js.md | 4 +- test/babel6/snapshots/plugins.js.snap | Bin 557 -> 559 bytes test/index.js | 44 ++++++++++++++- test/snapshots/attribute.js.md | 4 +- test/snapshots/attribute.js.snap | Bin 1528 -> 1530 bytes test/snapshots/external.js.md | 16 +++--- test/snapshots/external.js.snap | Bin 1655 -> 1658 bytes test/snapshots/index.js.md | 69 ++++++++++++++++++------ test/snapshots/index.js.snap | Bin 3056 -> 3245 bytes test/snapshots/macro.js.md | 6 +-- test/snapshots/macro.js.snap | Bin 547 -> 550 bytes test/snapshots/plugins.js.md | 4 +- test/snapshots/plugins.js.snap | Bin 557 -> 559 bytes 27 files changed, 174 insertions(+), 86 deletions(-) create mode 100644 css.mjs create mode 100644 src/decoys.js diff --git a/css.js b/css.js index 6521536a..b49a8b1f 100644 --- a/css.js +++ b/css.js @@ -1,23 +1,5 @@ -function notTranspiledError(name) { - throw new Error( - 'styled-jsx/css: if you are getting this error it means that your `' + - name + - '` tagged template literals were not transpiled.' - ) -} - -function css() { - notTranspiledError('css') -} - -css.global = function() { - notTranspiledError('global') -} - -css.resolve = function() { - notTranspiledError('resolve') -} +const { css, global, resolve } = require('./dist/decoys') module.exports = css -module.exports.global = css.global -module.exports.resolve = css.resolve +module.exports.global = global +module.exports.resolve = resolve diff --git a/css.mjs b/css.mjs new file mode 100644 index 00000000..855e1152 --- /dev/null +++ b/css.mjs @@ -0,0 +1,5 @@ +import decoys from './dist/decoys.js' + +export default decoys.css +export const global = decoys.global +export const resolve = decoys.resolve diff --git a/readme.md b/readme.md index a1af73af..a9771909 100644 --- a/readme.md +++ b/readme.md @@ -128,7 +128,7 @@ Turn on/off automatic vendor prefixing (default: `true`) The example above transpiles to the following: ```jsx -import _JSXStyle from 'styled-jsx/style' +import _JSXStyle from 'styled-jsx/style.js' export default () => (
diff --git a/src/_utils.js b/src/_utils.js index 564c8d50..ace427c5 100644 --- a/src/_utils.js +++ b/src/_utils.js @@ -678,7 +678,7 @@ export const booleanOption = opts => { export const createReactComponentImportDeclaration = () => t.importDeclaration( [t.importDefaultSpecifier(t.identifier(STYLE_COMPONENT))], - t.stringLiteral('styled-jsx/style') + t.stringLiteral('styled-jsx/style.js') ) export const setStateOptions = state => { diff --git a/src/babel-external.js b/src/babel-external.js index 8d8fb882..b98773f2 100644 --- a/src/babel-external.js +++ b/src/babel-external.js @@ -129,8 +129,11 @@ function addHash(exportIdentifier, hash) { export const visitor = { ImportDeclaration(path, state) { - // import css from 'styled-jsx/css' - if (path.node.source.value !== 'styled-jsx/css') { + // Bail if the import doesn’t have one of these specifiers: + // - styled-jsx/css + // - styled-jsx/css.mjs + // - 'styled-jsx/css.js + if (!/^styled-jsx\/css(?:\.m?js)?$/.test(path.node.source.value)) { return } @@ -218,7 +221,7 @@ export const visitor = { ) // When using the `resolve` helper we need to add an import - // for the _JSXStyle component `styled-jsx/style` + // for the _JSXStyle component `styled-jsx/style.js` if ( hasJSXStyle && taggedTemplateExpressions.resolve.length > 0 && diff --git a/src/decoys.js b/src/decoys.js new file mode 100644 index 00000000..80ff4a26 --- /dev/null +++ b/src/decoys.js @@ -0,0 +1,19 @@ +function notTranspiledError(name) { + throw new Error( + 'styled-jsx/css: if you are getting this error it means that your `' + + name + + '` tagged template literals were not transpiled.' + ) +} + +export function css() { + notTranspiledError('css') +} + +export function global() { + notTranspiledError('global') +} + +export function resolve() { + notTranspiledError('resolve') +} diff --git a/test/babel6/snapshots/attribute.js.md b/test/babel6/snapshots/attribute.js.md index 442b8aba..8a6eb7ee 100644 --- a/test/babel6/snapshots/attribute.js.md +++ b/test/babel6/snapshots/attribute.js.md @@ -8,7 +8,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ import styles from './styles';␊ ␊ const styles2 = require('./styles2');␊ @@ -108,7 +108,7 @@ Generated by [AVA](https://ava.li). `var _this = this;␊ ␊ - import _JSXStyle from "styled-jsx/style";␊ + import _JSXStyle from "styled-jsx/style.js";␊ export default (() => {␊ const Element = 'div';␊ return
␊ diff --git a/test/babel6/snapshots/attribute.js.snap b/test/babel6/snapshots/attribute.js.snap index 71641d5452193a9a442e05fb8dddb4e533583054..807a70db3a23c5577ec715795b28ed21013c7f45 100644 GIT binary patch literal 1532 zcmVocDK z?tBF9oVcyTSKz`8!8bri%#0l;PR7o}Zkv^s91{O|?>BFLzxUqQlU|`vcu@HAov;4- z_r33*_J01UGX3$7ANC65^UtF~q4@Tnv-->5pZ)Ug&9Hp=^0Pg9^|ucTg*OUsQLDW- z3lAUs{pd=y;l#br9T))l=@*Oocw*TuoP7HH>*wywKyYqbV-Os2tW_?Z>nc5zE*+s? zMAy_>!hklB3jASFMm+gTNp)A69&M zCKI4$@f3-tn8ovyc%EkV-1l62ir^yd8O1*kSJ3iH(2d4i4hZV!un~X!ix&epmVkX}-IPX^X<&Wkj2r+>T?TE7tAOx3R{z ztFl{$%T%?4vQ;>o-0WnEnG`DVmDPRE@Lr4s&nDP@CDVO$`&Ry839HJvos*k!DS|BP+6^G+T62 zh)D>WyKUSVktXpcEFfumPo(%bo02<=8i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- a/test/babel6/snapshots/external.js.md +++ b/test/babel6/snapshots/external.js.md @@ -8,7 +8,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ ␊ import colors, { size } from './constants';␊ const color = 'red';␊ @@ -98,7 +98,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ ␊ ␊ function test() {␊ @@ -112,7 +112,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ ␊ import colors, { size } from './constants';␊ const color = 'red';␊ @@ -168,7 +168,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ import styles from './styles2';␊ ␊ export default (({ level = 1 }) => {␊ @@ -184,7 +184,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ import styles from './styles';␊ const styles2 = require('./styles2');␊ import { foo as styles3 } from './styles';␊ @@ -211,7 +211,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ import styles, { foo as styles3 } from './styles';␊ ␊ const styles2 = require('./styles2');␊ @@ -229,7 +229,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ import styles from './styles';␊ ␊ export default (() =>
␊ diff --git a/test/babel6/snapshots/external.js.snap b/test/babel6/snapshots/external.js.snap index 84d466e7835d456466f7cf96358d6f119e394f13..c6656af2a46f3ad2137a1f9b3b09c146ab384ab7 100644 GIT binary patch literal 1501 zcmV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WOuyBmg`hT#r|+ujg8Aq3ko zGOvYAesa+F2TRzx|CwhD=UuX$Ie(DoUI%9xoMw8oZI91KQQNK6x#>D>bw+n)99>P` z&JNJ-&Wi5VPN;tl@OxVyLUqZ1oO@R5rfMIDt<1lz7Ay27YvFgdKe*d*dX%wQBS!)7 z9p_lpcb#Rotu1_)ws@Uw@%A23w&RSdpbC$}Dr!dvXyf)rshKLQ>E{)$Jf;#oaykR3 zbxK1LK)R{XcW4nMc+o$4mr!54#<;s3_~sKI)ZLkF-DH_@p^eBhDf~$M4@7OQA&nRS E047M{00000 diff --git a/test/babel6/snapshots/index.js.md b/test/babel6/snapshots/index.js.md index 687bb917..347a3505 100644 --- a/test/babel6/snapshots/index.js.md +++ b/test/babel6/snapshots/index.js.md @@ -8,7 +8,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ export default (() =>

test

woot

␊ @@ -28,7 +28,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ export default (() =>

test

woot

␊ @@ -40,7 +40,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ const Test = () => <_JSXStyle id={"2743241663"}>{"p{color:red;}"};␊ ␊ export default (() =>
␊ @@ -53,7 +53,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ const color = 'red';␊ const otherColor = 'green';␊ ␊ @@ -76,7 +76,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ const Test = () =>
test␊ @@ -87,7 +87,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ export default class {␊ ␊ render() {␊ @@ -103,7 +103,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ ␊ ␊ export default (({ children }) =>
␊ @@ -127,7 +127,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ export default (({ level = 1 }) => {␊ const Element = `h${level}`;␊ ␊ @@ -158,7 +158,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ export default class {␊ render() {␊ const Element = 'div';␊ @@ -184,7 +184,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ const darken = c => c;␊ const color = 'red';␊ const otherColor = 'green';␊ @@ -215,7 +215,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ const Test = () =>
␊ <_JSXStyle id={"2209073070"}>{"body{color:red;}:hover{color:red;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-animation:foo 1s ease-out;animation:foo 1s ease-out;}div a{display:none;}[data-test]>div{color:red;}"}
;␊ @@ -226,7 +226,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ const attrs = {␊ id: 'test'␊ };␊ @@ -257,7 +257,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ export default (() =>

woot

␊ @@ -268,7 +268,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ export default (() =>

test

woot

␊ diff --git a/test/babel6/snapshots/index.js.snap b/test/babel6/snapshots/index.js.snap index 985b671e737f3eedb2720d932b8afcab65653f6e..98c7a84dfc46124931869a96728a63b7c51990cc 100644 GIT binary patch literal 2491 zcmV;s2}JfmRzV4fVvn&)upf&E00000000B+ zS#N9`XBj`ID;p6T3{clHhF-j|i<{ZLKmKzU*IAQvOPsk`+jRNcDmmZ1i7!3hnY(iw z$33P3A5gUqo!A5$Fa{H4h-s6MkPy-|p#j>Lp=q1whXE2u(2e!OC=x1b)$-nJ`+S$! zj-7T}RbeUd`FWrBd7t<9{C(eh)JG7XCSE-we&STu)57`i*G7)4zWFOeM4!XxtLICP z{3rakXP*A+Q-ROD|I+AxeVF=O7eQRS^Of)XGX3uEzn_+WzN2&^;KS5EY$J%Zf1liW z^1k$^o(E5!yZDlMz=x?{xrrbypF8}oCx+jA=k}9(cfNZ3h1YzT`oVUB_~c#EPfNf3 zAb<1Y@BZ=6-ETeX!_>ELA&9e2?*884wUr0o`{6)r`}beD;KNjDdpE!e3*LXR)UayJr^@iT-uR&oZf!wCsTwEQ{TCbARhW%;JY*5-u~>5EXU{XQzi?TaIrR3n&-gHP#xv>;(MpTBViw==I$nlZN$wOci(p6_OAPVaxSmwCYT?an4U083IvO~ zmII_=KTE-7V>OH)L(2x4=!UD9S%Ql~K`}vZZvZ3*z#d6n0iq%p#<-A!$+92K3NrBs z%S7l{jP+Xs-2i>|Pm7tC=E@Q=YXcly}3EDJ8 zbCD<;rD|w5!^O?$LA)V0Zf*w~hu9JuEDz(8K)jpV6d}8=n5G zwgPn*MUsuYB9!`rMVL7zo575>x`DQ+Ko>D*V1kp@vs;Mwx%}IhO1a0RyI)KL8h=4@53rVI9OpxGeUC4vADBen`(-3MCrqs>XdPK( zcv{SjE9ogZD~|3j2r3?T);`Ga1!-imAPuKtQ>8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/macro.js.md index eecb7c37..c6193f40 100644 --- a/test/babel6/snapshots/macro.js.md +++ b/test/babel6/snapshots/macro.js.md @@ -8,7 +8,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ ␊ ␊ ({␊ @@ -20,7 +20,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ ␊ ␊ function test() {␊ @@ -34,7 +34,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ ␊ ␊ const { className, styles } = {␊ diff --git a/test/babel6/snapshots/macro.js.snap b/test/babel6/snapshots/macro.js.snap index 532e5ab0a1fda95b521655e4fdf40c5bf1aa9362..2c178ddf00de192250470d463c7ec153bdd2e5fd 100644 GIT binary patch delta 518 zcmV+h0{Q)%1fK*VK~_N^Q*L2!b7*gLAa*he0ss&jF08^pB+ZFCQ!Lh|`&^MCC4YN? z_)Yu{sbZ~5X|E^p%|7BMXu=2y@kY7}y5bqTn5nNK4ld6zbl%K1hUJPQV=w=mH=!2PhS;gwsTwGil)m#cd z02V8@Qm{ej%S^GYRx+}%Ff%nUF@G~MP^z`7R!Ye%18S_$MF>|X=jY@XSrw(GSl24m z+UUde+v$J}PR>azF7`{zO|?=`N7bp$RjX-@;`n2vIzFv5FS#T$KTn|~wYWq>Qvu|c zf%K4q0?HRwU*Yc>N&~DB zWVC`pQEEwPQJ#Vg(7y<+w$*TEtsOXnD=1{-m#0)h+0_t}Yr$L_eV|@DU=Fti07;Zr IV#x&n08_;5ApigX delta 515 zcmV+e0{s1-1e^pSK~_N^Q*L2!b7*gLAa*he0suY|Zo%QFdban+)I-szIBAh0C4aks z_)Yu{sbZ~5X|E^p%|7BMXu=2JOm_v_*0#fOjgGlE5PSV88ogY`4A zG6*uQX2{Gf$S*2Ui1!MP2rjA2NmWQI%Fk6$F9xwwbhC;p^ubJZYc4J>jcP6hAOH&# zTPfHeG-amPRx24mr1!lk;=(i>!)LQ><&1YHjr4 z`t5YU1}Env78m;^=B8RHsH5ss=c?7TMsfLJl3bovnwMOXnV+Xnl3HA%p{W4!$Uyo= zK>_F=u38iyU1TQ3N6Gnl#U%>W2wQZZK2fMuum$@Mr^gITjf^Z!3@r^&J%0ul#_ur< zZ^88eBgq=(u$0QY#N5o}V2G1!6$*;-3xKp8B-C*_&CH32N^2<{yq3mji$+cjvjXqGX9WZ-a0|224F*Cpg F008-L@8SRe diff --git a/test/babel6/snapshots/plugins.js.md b/test/babel6/snapshots/plugins.js.md index 546b315c..d4c9f73c 100644 --- a/test/babel6/snapshots/plugins.js.md +++ b/test/babel6/snapshots/plugins.js.md @@ -8,7 +8,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ import styles from './styles';␊ const color = 'red';␊ ␊ @@ -39,7 +39,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from 'styled-jsx/style';␊ + `import _JSXStyle from 'styled-jsx/style.js';␊ import styles from './styles';␊ const color = 'red';␊ ␊ diff --git a/test/babel6/snapshots/plugins.js.snap b/test/babel6/snapshots/plugins.js.snap index 1a809ca17811d093cc5820870e5a0d347dd00417..21d717681d581aad84356ca0c2c5b4b61f6b9b57 100644 GIT binary patch literal 559 zcmV+~0?_?IRzVO6F|xByz8&GAr+NBwE!H7zCJ~6#;+ReuQ*Ll(FG%QK}^Hrt{rL6B8g>OWJ z_(ng1n4%Tm7{L+3A{Gfu0>~1QmJwwzXH_CekvOdhy6|c;mW#!w-QDL000Le0{H*{ literal 557 zcmV+|0@D3KRzVqN*M6ii@!kh z)-sgSZ=gs@f3i?C|FV!!V;`Xt3fOtnIRCTOAFnSus_}Dw0mvm?mY!ILdgHh!ZSN>yj?Lnv4rZ=a!HmPJ$Yx(^=%)6a{Bb vl4$lQ!(lwdY@s!ylg!6kC|v|&_JGh4A}5d#o^A>KoPVF6!kEMLKm`B*YHt*( diff --git a/test/index.js b/test/index.js index 39fb1006..9b4cddf5 100644 --- a/test/index.js +++ b/test/index.js @@ -5,7 +5,7 @@ import ReactDOM from 'react-dom/server' // Ours import plugin from '../src/babel' -import _transform from './_transform' +import _transform, { transformSource as _transformSource } from './_transform' const transform = (file, opts = {}) => _transform(file, { @@ -13,6 +13,12 @@ const transform = (file, opts = {}) => ...opts }) +const transformSource = (src, opts = {}) => + _transformSource(src.trim(), { + plugins: [[plugin, opts]], + ...opts + }) + test('handles dynamic `this` value inside of arrow function', async t => { const { code } = await transform( './fixtures/dynamic-this-value-in-arrow.js', @@ -267,3 +273,39 @@ test('optimized styles do not contain new lines', t => { t.is(html, `${expected}`) }) + +test('Babel plugin matches import specifier styled-jsx/css', async t => { + const { code } = await transformSource(` + import css from 'styled-jsx/css' + + css.resolve\`div { color: red }\` + `) + t.snapshot(code) +}) + +test('Babel plugin matches import specifier styled-jsx/css.mjs', async t => { + const { code } = await transformSource(` + import css from 'styled-jsx/css.mjs' + + css.resolve\`div { color: red }\` + `) + t.snapshot(code) +}) + +test('Babel plugin matches import specifier styled-jsx/css.js', async t => { + const { code } = await transformSource(` + import css from 'styled-jsx/css.js' + + css.resolve\`div { color: red }\` + `) + t.snapshot(code) +}) + +test('Babel plugin doesn’t match an unrelated import specifier', async t => { + const { code } = await transformSource(` + import css from 'x' + + css.resolve\`div { color: red }\` + `) + t.snapshot(code) +}) diff --git a/test/snapshots/attribute.js.md b/test/snapshots/attribute.js.md index 594ec1a8..c226a2c6 100644 --- a/test/snapshots/attribute.js.md +++ b/test/snapshots/attribute.js.md @@ -8,7 +8,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ import styles from './styles';␊ ␊ const styles2 = require('./styles2'); // external only␊ @@ -112,7 +112,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ export default (() => {␊ const Element = 'div';␊ return
␊ diff --git a/test/snapshots/attribute.js.snap b/test/snapshots/attribute.js.snap index 6130091626d9dc65a2fdf35bea7a13d4cdbf3a43..5e980061eb8715a23d7c2437baf227f00b01846d 100644 GIT binary patch literal 1530 zcmVhE;e?j5T^34t4@F}k5gGPEZ zg+fY*izT>x5nk#}{s?1EWc1jXlnB#o(j(MVSFPhqBWjSD3md*HGoh$OJbCQN7xA26 z&q-m=BhR%L5PSr9BDuta0pNMR5THP2fsh^%EF#3V2uw()l#pXejKrUbSC(!HJm70( zV98uj?ojkHNTjSVZ4_xh(z0A^B`I6gPWib-`vldr9P0}c^=jROS{V>h_9gr;RKtNO z0AXJ!QLDF#!O)*}K;dRQx2?Iu*n^2J7M*-a?zo$m5Sc-CWQ>l#+U#qA9ps*!+V?lE zpdjun_Pb<`bYFnl??xZN&39ihh`ScxXJo)VOjrApj-la!3kYM{TPMAlVd+Km_m2`7&|L~5QIGr=7*6yw-{-0K2vQ* zg^(qd0evLv6Tg7v!DD8slSWRiz!+KD%VY~_C9oCUeb4Y-qGIni2vevP&5+dw6Js}E zFlQKSKMUh}M^4w!XtBLAk3(#V@c_K3WmxvWhT72Q{F6rLPZ3WV$YngN`n6$f2k`d? zxpn{pV{*o!mb^#}9DZ1>(tSXBEP)Yf{@*Ti8w#P3#Mg$P(E#w;g|?|0z%q?xwYu6` zr2bzZDO$*z?k{dO^$DK%kw@{w^Ycs9x%5Hwq_jFa3HB9F=EVVGk)AZ>0b*RAIMz5g zPLLtVP1^L6HXQ@?V#KMYhKN>OeVV|Yl*%5>+kQ`yC0Xt$bU!MIkYw)ixF>{~#viwa zB>6oTvWVR zcMMJm`q|l8jXisd;wMc!Rig-szcLbeLZ5NG}k9RO?T#o zx*X`Hp_{P&%&?}d5& z(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Q2BH{NK(E2MUpq%-05>(E#w;gN~({z_!dqwYuC_ zr2bzZ9VFyUHy77C`WVmp(5HCf+1aJ$UIrk3QeK`NhntGWv*G}WNRJz{5HTrE5^EG5 zr)ZGoCa?R+>yDvx3F0(MM?`C$F-c)h&SZ}!ZLcdUvZAzAx*3&5NIG}BxTl1g#UHnV zB*{G!ljCel?ILPqk*Y5&ZJNqz3$sf1x=}Q!keJhR9QB4M1Th>(I62{@Uc1xow%clx zI|3&J{q*#-#-6=J@zW-rsZk6iSQ-!g5Dw8io}qAXbR@QVXi;~e2`8TIgc=^w&tQO3 zH{N9*C^*S$;#8Xn0yaJZ24&JTz%#fQ z`bMxlO;Kx5l~z~nB$kcUJ`e_u{U2#P6Ibr(>xPK^OW(Qz@CkweANU3eNeaSbG>uU$ eUgL8!zHdk9<3>LDM38fnWbS`Mq@O(~CIA4rPwuw> diff --git a/test/snapshots/external.js.md b/test/snapshots/external.js.md index e1f84dcb..2951c2e0 100644 --- a/test/snapshots/external.js.md +++ b/test/snapshots/external.js.md @@ -8,7 +8,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ import colors, { size } from './constants';␊ const color = 'red';␊ const bar = ["div.jsx-2141779268{font-size:3em;}"];␊ @@ -55,7 +55,7 @@ Generated by [AVA](https://ava.li). `"use strict";␊ ␊ - var _style = _interopRequireDefault(require("styled-jsx/style"));␊ + var _style = _interopRequireDefault(require("styled-jsx/style.js"));␊ ␊ var _App = _interopRequireDefault(require("./App.styles"));␊ ␊ @@ -99,7 +99,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ ␊ function test() {␊ ({␊ @@ -112,7 +112,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ import colors, { size } from './constants';␊ const color = 'red';␊ const bar = new String("div.jsx-2141779268{font-size:3em;}");␊ @@ -158,7 +158,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ import styles from './styles2';␊ export default (({␊ level = 1␊ @@ -174,7 +174,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ import styles from './styles';␊ ␊ const styles2 = require('./styles2');␊ @@ -201,7 +201,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ import styles, { foo as styles3 } from './styles';␊ ␊ const styles2 = require('./styles2');␊ @@ -219,7 +219,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ import styles from './styles';␊ export default (() =>

test

␊ diff --git a/test/snapshots/external.js.snap b/test/snapshots/external.js.snap index b7551ed60d84d0cf9af4b41aecf862a1881b0c47..60d66372439682e24b18e2fc2c35a61594989b8c 100644 GIT binary patch literal 1658 zcmV-=28H=SRzVK0kIib?!X>D@Ualx&b)3?8*Im9xflgJbL!& zgU{_d#8K&`l>of-%WIcU2KIjV)X0{u)47LEa8!EWb^yM*_isLXXY~BhFV?I-{qp@U za#VWl4ghWdH_?1>OTmgIr$MDwmlX}>9~|90s_m*GIHt%o$gAXgX<(Z=5u{%O+f+W~ z^Nls6qE?Y5s3BGJ_razQLO=NjAswbBVcLeOl!lwU5Rb>AgOQjp$m^LVU#jfDSQ7)b zxLK5|vXWF#DW&szI%w%<`YCX+Dyr&6v4)b6cWUzZz22Ad>5iB*j&G<4`=eBf8gY7u zsK7jR4-Uh8MbeNW*B?RK8x;kuM`L26s`(Z6)897mzCIIWUA^uBBM`*n0xTg+*~(i7 zRe9?+oJ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_P7=vS1vjb4qpE>}|;OO)_Dk?cn(aj-H4i`M8 z3vMBg4L%mC?@L?Gn?*@2L)pL}pXlvfg<`3oV~kZBFzuw`E(tL&LJ=P(&@l%swM;8i zcH4eX7bajPXtUbOcc|OxWYo=>1ih~=!I5Ok+_zr3Sj-KVe(g79iGJtNyvDiI9K`qI zgOv``Bz+_(xutlZRFLN$9-fj8?;P`M#iJ@cyf^E6MzF7K>^#)UP!Tx!zF07 z8peV~50#nvVuGUK9C6}Mnn*qHtwknSUy7-;>|RM~0k?~oPQ7)$)(tix>h2hEIz~D; zE_y*|LgocR+iq-PlZzdyx|XqZKQVV|=TovjIIn%W^Wdbx=|-bQ4O%?lrC3P&W@?5g^*YwV(xMVN0{93|j8wJ3gptHMcGMfC`y^OgNjGF*i<`VLhn_ch5l z{I+Oa85;v;ZCXpvWK Snapshot 1 + + `import _JSXStyle from "styled-jsx/style.js";␊ + ({␊ + styles: <_JSXStyle id={"2886504620"}>{"div.jsx-2886504620{color:red;}"},␊ + className: "jsx-2886504620"␊ + });` + +## Babel plugin matches import specifier styled-jsx/css.js + +> Snapshot 1 + + `import _JSXStyle from "styled-jsx/style.js";␊ + ({␊ + styles: <_JSXStyle id={"2886504620"}>{"div.jsx-2886504620{color:red;}"},␊ + className: "jsx-2886504620"␊ + });` + +## Babel plugin matches import specifier styled-jsx/css.mjs + +> Snapshot 1 + + `import _JSXStyle from "styled-jsx/style.js";␊ + ({␊ + styles: <_JSXStyle id={"2886504620"}>{"div.jsx-2886504620{color:red;}"},␊ + className: "jsx-2886504620"␊ + });` + ## generates source maps > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ export default (() =>

test

woot

␊ @@ -19,7 +49,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ import React, { Component } from 'react';␊ export default class Index extends Component {␊ static getInitialProps() {␊ @@ -72,7 +102,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ export default (() =>

test

woot

␊ @@ -84,7 +114,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ ␊ const Test = () => <_JSXStyle id={"2743241663"}>{"p{color:red;}"};␊ ␊ @@ -98,7 +128,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ const color = 'red';␊ const otherColor = 'green';␊ ␊ @@ -121,7 +151,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ ␊ const Test = () =>
test␊ @@ -133,7 +163,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ export default class {␊ render() {␊ return
␊ @@ -148,7 +178,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ export default (({␊ children␊ }) =>
␊ @@ -172,7 +202,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ export default (({␊ level = 1␊ }) => {␊ @@ -203,7 +233,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ export default class {␊ render() {␊ const Element = 'div';␊ @@ -229,7 +259,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ ␊ const darken = c => c;␊ ␊ @@ -265,7 +295,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ import React from 'react';␊ export default (() => <>␊

Testing!!!

␊ @@ -300,7 +330,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ ␊ const Test = () =>
␊ <_JSXStyle id={"2209073070"}>{"body{color:red;}:hover{color:red;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-animation:foo 1s ease-out;animation:foo 1s ease-out;}div a{display:none;}[data-test]>div{color:red;}"}␊ @@ -312,7 +342,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ const attrs = {␊ id: 'test'␊ };␊ @@ -344,7 +374,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `import _JSXStyle from "styled-jsx/style";␊ + `import _JSXStyle from "styled-jsx/style.js";␊ export default (() =>

woot