wbyoung / babel-plugin-transform-postcss

Babel PostCSS Transform
MIT License
55 stars 23 forks source link

Add support for transpiling import statements #28

Closed adierkens closed 7 years ago

adierkens commented 7 years ago

With growing support for module builds of components (from rollup and webpack), there's a need to transform postcss without transforming import statements to require ones.

This adds support for the { modules: false } babel-config option, which skips transforming import statements to require's

Fixes #27

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-76.4%) to 23.611% when pulling 367c85c03d05eb36c2a4e79097f8fa0dd8385214 on adierkens:no-modules into 55679c22334d8f8bc38d0bbf050f943c1dd63e6d on wbyoung:master.

adierkens commented 7 years ago
% npm test                                                                                                                                   on no-modules|…

> babel-plugin-transform-postcss@0.1.1 test /Users/adierkens/Developer/babel-plugin-transform-postcss
> eslint . && flow check && BABEL_ENV=coverage nyc mocha

Found 0 errors

  babel-plugin-transform-postcss
    when transforming require.js
      ✓ launches the server
      ✓ launches a client
      ✓ compiles correctly
      when transforming require.js
        ✓ does not launch the server again
    when transforming import.js
      ✓ launches the server
      ✓ launches a client
      ✓ compiles correctly
      when transforming require.js
        ✓ does not launch the server again
    when transforming nocss.js
      ✓ does not launch the server
      ✓ does not launch a client
    when transforming import.no.name.js
      ✓ does not launch the server
      ✓ does not launch a client
    when transforming import.nocss.js
      ✓ does not launch the server
      ✓ does not launch a client
    when transforming import.js without modules
      ✓ launches the server
      ✓ launches a client
      ✓ compiles correctly
      when transforming require.js
        ✓ does not launch the server again
    when the server has been started started
      when transforming require.js
        ✓ does not launch the server again
    when transforming require.js & the client returns no data
      ✓ compiles correctly

  postcss-client
    with a server to connect to
      main(...testArgs)
        ✓ sends client message to server
        ✓ writes server response to stdout
        ✓ succeeds during first connect attempt
    main(...testArgs)
      ✓ attempts to re-connect

  postcss-server
    main(...testArgs)
      ✓ starts a server
      ✓ observes SIGINT to cleanup server socket
      ✓ accepts JSON details and extracts PostCSS modules (242ms)
      ✓ fails gracefully for invalid CSS
      with a cached result
        ✓ accepts JSON details and extracts PostCSS modules
      with an invalid cache
        ✓ does not contain a response
        ✓ logs a useful message
      with a missing CSS file
        ✓ does not contain a response
        ✓ logs a useful message
      with a missing config file
        ✓ does not contain a response
        ✓ logs a useful message
    when listen fails
      ✓ fails to complete main(...testArgs)
    when the server socket already exists
      main(...testArgs)
        ✓ exits
        ✓ logs a useful message
      when stderr is a TTY
        main(...testArgs)
          ✓ logs with color
    when making a directory fails
      ✓ errors when invoking main

  40 passing (452ms)

-------------------|----------|----------|----------|----------|----------------|
File               |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
-------------------|----------|----------|----------|----------|----------------|
All files          |      100 |      100 |      100 |      100 |                |
 plugin.js         |      100 |      100 |      100 |      100 |                |
 postcss-client.js |      100 |      100 |      100 |      100 |                |
 postcss-server.js |      100 |      100 |      100 |      100 |                |
-------------------|----------|----------|----------|----------|----------------|

Not sure what's up with the travis build. Tests run fine locally.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 367c85c03d05eb36c2a4e79097f8fa0dd8385214 on adierkens:no-modules into 55679c22334d8f8bc38d0bbf050f943c1dd63e6d on wbyoung:master.

bzang commented 7 years ago

Any word on when this will get merged in? Having this support will be incredibly helpful!

adierkens commented 7 years ago

@wbyoung Thanks for reviewing! I made the changes you requested

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 1701d410471c669739704fafae0341e0d5ac6517 on adierkens:no-modules into f978f5b99082f04bae7596b98f4870c0456f6c0d on wbyoung:master.

wbyoung commented 7 years ago

Just released in 0.2.1.