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

transform not working for windows #17

Closed
VikasAgarwal1984 opened this issue Apr 3, 2022 · 2 comments · Fixed by #26
Closed

transform not working for windows #17

VikasAgarwal1984 opened this issue Apr 3, 2022 · 2 comments · Fixed by #26

Comments

@VikasAgarwal1984
Copy link

VikasAgarwal1984 commented Apr 3, 2022

Sample Code:
https://github.com/VikasAgarwal1984/package-deploy-learn/tree/0.0.1

Issue:
Transform not working

Jest config file path
https://github.com/VikasAgarwal1984/package-deploy-learn/blob/0.0.1/jest.config.js

To understand what is failing, i updated the index file in node_modules to the content copied in below link:
https://github.com/VikasAgarwal1984/package-deploy-learn/blob/0.0.1/dev/index.js

I think the issue is
require("${postcssRunner}")(

does not work as everything is Stringified, and ${} flat the '' in windows. so when code gets evaluated it fails.
To double check, i debugged with following paths:


// works
    // const postcssRunner = 'D:\\\\git\\\\package-deploy-learn\\\\node_modules\\\\jest-transform-css\\\\postcss-runner.js';
    //const postcssRunner = 'D:/git/package-deploy-learn/node_modules/jest-transform-css/postcss-runner.js';

    // does not work
    const postcssRunner = `${__dirname}/postcss-runner.js`;
    //const postcssRunner = p.normalize(`${__dirname}/postcss-runner.js`);
    //const postcssRunner = 'D:\\git\\package-deploy-learn\\node_modules\\jest-transform-css\\postcss-runner.js';
    //const postcssRunner = 'D:\\git\\package-deploy-learn\\node_modules\\jest-transform-css/postcss-runner.js';


\\\\ gets translate to \\ in  require("${postcssRunner}") and path works.

I tested above Repository in Ubuntu VM, there was no issue, and npm run test works fine.
Any insights?

@dferber90
Copy link
Owner

dferber90 commented Apr 4, 2022

Thanks for your nice report! Maybe using path.join could work?

So something like const postcssRunner = path.join(__dirname, "postcss-runner.js") could do the trick?

@VikasAgarwal1984
Copy link
Author

I think issue is with below line:

File:
https://github.com/dferber90/jest-transform-css/blob/master/index.js

Line No: 71
require("${postcssRunner}")(

We need to preserve'\\',
Something like below should work I believe.
https://stackblitz.com/edit/web-platform-zoctv4?file=script.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants