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

Windows Support / export FilterError #11

Open
FSE-DEV opened this issue Apr 23, 2019 · 5 comments
Open

Windows Support / export FilterError #11

FSE-DEV opened this issue Apr 23, 2019 · 5 comments

Comments

@FSE-DEV
Copy link

FSE-DEV commented Apr 23, 2019

In Windows 10 environment a FilterError(err) in raised: "compressor.exception.FilterError: 'export' is not recognized".

Regarding the issue and answer here: https://stackoverflow.com/questions/55029689/use-django-compressor-es6compiler-under-windows - is Windows supported at all? If so, what cofigurations / adjustments are missing?

Thank you.

@fermartsdc
Copy link

Hi, I need to know if this issue will be solved, I have the same problem with the es6compiles in windows.

@datablackhole
Copy link

same here

@kottenator
Copy link
Owner

Sorry, it's been awhile since I visited my project last time. Too much work to do on my job.

is Windows supported at all?

I have designed it to work on any platform where the underlying Node libraries work (I mean node-sass, less, etc).

But I have tested it only on Linux / macOS :)

Indeed, the problem is in the COMPRESS_ES6_COMPILER_CMD setting - its default value is for UNIX / Linux systems:

COMPRESS_ES6_COMPILER_CMD = 'export NODE_PATH="{paths}" && '
        '{browserify_bin} "{infile}" -o "{outfile}" '
        '-t [ "{node_modules}/babelify" --presets="{node_modules}/babel-preset-es2015" ]'

I'm not very familiar with Windows CMD way of setting the NODE_PATH env variable right in the command line.

If you will figure it out - just set your custom Django setting:

# settings.py
COMPRESS_ES6_COMPILER_CMD = '<set the NODE_PATH env var to {paths} somehow and call> '
        '{browserify_bin} "{infile}" -o "{outfile}" '
        '-t [ "{node_modules}/babelify" --presets="{node_modules}/babel-preset-es2015" ]'

If it's not possible through the CMD then it should be possible from Python:

os.environ["NODE_PATH"] = ...

But this would require a pull-request to this project.

And I'm really sorry but I'm still very busy at my main job, so I appreciate your help with the pull-request ;)

@Andrioden
Copy link

Andrioden commented May 18, 2023

I am trying to get this to work on windows.

This is as close as i got

settings.py

COMPRESS_ES6_COMPILER_CMD = '$env:NODE_PATH="{paths}" && {browserify_bin} "{infile}" -o "{outfile}" -t [ "{node_modules}/babelify" --presets ["{node_modules}/@babel/preset-env"] ]'
(untitledgame) PS C:\Projects\untitledgame> python manage.py compress
CommandError: An error occurred during rendering game\index.html: The filename, directory name, or volume label syntax is incorrect.
Compressing...

game\index.html

    {% compress js %}
		{% include "game/parts/scripts_libs.html" %}
	{% endcompress %}

    {% compress js %}
        {% include "game/parts/scripts_game.html" %}
        <script src="{{ STATIC_URL }}custom/js/main-common.js" type="module"></script>
        <script src="{{ STATIC_URL }}custom/js/main-game.js" type="module"></script>
    {% endcompress %}

I have verified browserify and babel actually works by running a command directly. This command works:

.\node_modules\.bin\browserify ".\static\custom\js\main-game.js" -o bundle.js -t [ "./node_modules/babelify" --presets ["./node_modules/@babel/preset-env"] ]

@Miitto
Copy link

Miitto commented Jun 10, 2023

if os.name == 'nt':
    COMPRESS_ES6_COMPILER_CMD = 'set NODE_PATH="{paths}" && {browserify_bin} "{infile}" -o "{outfile}" -t [ "{node_modules}\\babelify" --presets="{node_modules}\\babel-preset-es2015"]'
    COMPRESS_BROWSERIFY_BIN = 'node_modules\\.bin\\browserify'

This gets past an initial error, however ended up with a EPERM rename error, which seems to be related to the TemporaryNamedFile, using an absolute output file path avoids this, however Django can still not properly run the code

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

No branches or pull requests

6 participants