Git Product home page Git Product logo

Comments (9)

spectras avatar spectras commented on June 10, 2024

Note: a quick-and-dirty change in karma-rollup-preprocessor/lib/Watcher.js like this:

-		this.emitter._fileList.changeFile(path, true)
+		this.emitter._fileList.changeFile(path.replace(/\\/g, '/'), true)

…makes it work on my system.

That would however break projects that actually use backslashes in file names on posix systems. Perhaps check the value of require('path').sep instead of replacing unconditionally?

from karma-rollup-preprocessor.

jlmakes avatar jlmakes commented on June 10, 2024

Something like this?

const sep = require('path').sep

//...

this.emitter._fileList.changeFile(sep !== '/' ? path.replace(/\\/g, '/') : path, true)

from karma-rollup-preprocessor.

Lalem001 avatar Lalem001 commented on June 10, 2024

@jlmakes path.normalize might work here. Not at my computer, so cannot double check.

from karma-rollup-preprocessor.

Lalem001 avatar Lalem001 commented on June 10, 2024

Took a look, and my above comment with path.normalize will not work.

Take a look instead at slash.

Convert Windows backslash paths to slash paths: foo\\bar βž” foo/bar

from karma-rollup-preprocessor.

jlmakes avatar jlmakes commented on June 10, 2024

It's basically a wrapper around the same string replace:

// slash.js

'use strict';
module.exports = path => {
	const isExtendedLengthPath = /^\\\\\?\\/.test(path);
	const hasNonAscii = /[^\u0000-\u0080]+/.test(path);

	if (isExtendedLengthPath || hasNonAscii) {
		return path;
	}

	return path.replace(/\\/g, '/');
};

I understand testing for ASCII, but I had to search for "extended length paths":
https://stackoverflow.com/questions/21194530/what-does-mean-when-prepended-to-a-file-path

from karma-rollup-preprocessor.

Lalem001 avatar Lalem001 commented on June 10, 2024

I know, was just thinking that it could potentially handle the edge cases for you if they ever came up.

from karma-rollup-preprocessor.

jlmakes avatar jlmakes commented on June 10, 2024

I'm generally cautious of adding dependencies, but I'm not opposed to it. I just don't fully understand if those cases are overly defensive for Karma and Rollup. As in, will non-ASCII or extended length paths occur in a JavaScript code base, or the build process therein?

That would however break projects that actually use backslashes in file names on posix systems. β€” @spectras

This would still need to be addressed in the implementation. So, something like this?

const slash = require('slash')
const sep = require('path').sep

//...

this.emitter._fileList.changeFile(sep !== '/' ? slash(path) : path, true)

from karma-rollup-preprocessor.

Lalem001 avatar Lalem001 commented on June 10, 2024

Just want to point out that \u0000 does show up when certain rollup plugins are involved.

from karma-rollup-preprocessor.

spectras avatar spectras commented on June 10, 2024

Good news and bad news!

Bad news: 5668d68 does not work here.

Good news: the fix in it works.

  • After seeing 5668d68 did not work, I tried 7.0.4, and I have the same problem in it.
  • So I downgraded to 7.0.3 and backported the commit. This worked and I confirm it fixes the issue.

So, the fix works, but 7.0.4 introduced another issue. I'll open a separate topic.

from karma-rollup-preprocessor.

Related Issues (20)

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.