Giter VIP home page Giter VIP logo

esbuild-plugin-css-modules's People

Contributors

atomicpages avatar koluch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

esbuild-plugin-css-modules's Issues

Does not work on Windows

This plugin fails on Windows because of backslashes in paths.

This is my case:

esbuild.build({
  entryPoints: [ './src/index.js' ],
  bundle: true,
  outfile: './dist/bundle.js',
  plugins:
    [ esbuild_sass()
    , esbuild_css_modules(
    { localIdentName: "[local]--[hash:8:md5:hex]"
    , extension: '.module.css'
    }
    )
    ],
  minify: !isDev(),
  minifyIdentifiers: !isDev(),
  minifySyntax: !isDev(),
  minifyWhitespace: !isDev(),
  sourcemap: isDev() ? 'external' : false,
  platform: 'browser'
})

Which currently produces this result:

Error: Build failed with 1 error:
../../../AppData/Local/Temp/tmp-5848-66jQXSM4BQce/nuts/src/index.module.css:2:15: error: Could not resolve "C:Users\rmancAppDataAppDataLocalTemp\tmp-5848-66jQXSM4BQce\nutssrcindex.css" (mark it as external to exclude it from the bundle)
    at failureErrorWithLog (C:\Users\rmanc\Documents\projs\nuts\node_modules\esbuild\lib\main.js:1449:15)
    at C:\Users\rmanc\Documents\projs\nuts\node_modules\esbuild\lib\main.js:1131:28
    at runOnEndCallbacks (C:\Users\rmanc\Documents\projs\nuts\node_modules\esbuild\lib\main.js:921:63)
    at buildResponseToResult (C:\Users\rmanc\Documents\projs\nuts\node_modules\esbuild\lib\main.js:1129:7)
    at C:\Users\rmanc\Documents\projs\nuts\node_modules\esbuild\lib\main.js:1236:14
    at handleIncomingPacket (C:\Users\rmanc\Documents\projs\nuts\node_modules\esbuild\lib\main.js:706:9)
    at Socket.readFromStdout (C:\Users\rmanc\Documents\projs\nuts\node_modules\esbuild\lib\main.js:576:7)
    at Socket.emit (events.js:376:20)
    at addChunk (internal/streams/readable.js:309:12)
error Command failed with exit code 1.

I noticed the path C:Users\rmancAppDataAppDataLocalTemp\tmp-5848-66jQXSM4BQce\nutssrcindex.css and looked at the source:

let contents = `
import "${tmpFilePath}";
const result = ${JSON.stringify(classMap)};
export default result;
`;

The generated code looks like this:

import "C:\Users\rmanc\AppData\AppData\Local\Temp\tmp-5848-66jQXSM4BQce\nuts\src\index.css";
const result = {"test":"test--h0aba64c6"};
export default result;

which obviously doesn't work.

--

I've managed to make it work by wrapping tmpFilePath with https://github.com/sindresorhus/slash.

I'm writing a PR addressing this issue.

Result map is incorrect

I'm trying this out with the latest esbuild 0.12.5, via a hacked-together version of snowpack, so I could have broken something there, but I'm finding that the output is mapping the wrong thing, I get values like:

var result3 = { "_Input_12syk_1": "h420205b8d955473ee51fd9760bbe0f66", "_Input___error_12syk_51": "hcc1aea921f960ec121be40adeeaf789b" };
var Input_module_default = result3;

Where I thought the keys should be something like just Input and the value should be _Input_12syk_1.

[ERROR] Could not resolve (... some temp file)

I am sporadically getting these messages when I try to chain esbuild-plugin-sass followed by esbuild-plugin-css-modules.

The error is not happening consistently, so I assume it's some sort of race condition.

❯ ./build.js
✘ [ERROR] Could not resolve "/var/folders/tg/vwvky4sd66vgvjkl0njrkl000000gn/T/tmp-87375-BNfLN4lwtij1/scrapbook-browser/lib/style/login.css"

    ../../../../../../var/folders/tg/vwvky4sd66vgvjkl0njrkl000000gn/T/tmp-87375-BNfLN4lwtij1/scrapbook-browser/lib/style/login.module.css:2:15:
      2 │         import "/var/folders/tg/vwvky4sd66vgvjkl0njrkl000000gn/T/tmp-87375-BNfLN4lwtij1/scrapbook-browser/lib/style/login.css";
        ╵                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "/var/folders/tg/vwvky4sd66vgvjkl0njrkl000000gn/T/tmp-87375-bqafdvagfR2x/scrapbook-browser/lib/style/login.css"

    ../../../../../../var/folders/tg/vwvky4sd66vgvjkl0njrkl000000gn/T/tmp-87375-bqafdvagfR2x/scrapbook-browser/lib/style/login.module.css:2:15:
      2 │         import "/var/folders/tg/vwvky4sd66vgvjkl0njrkl000000gn/T/tmp-87375-bqafdvagfR2x/scrapbook-browser/lib/style/login.css";
        ╵                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.