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

Noop in environment without DOM api #595

Closed
OlegWock opened this issue Feb 28, 2023 · 1 comment · Fixed by #597
Closed

Noop in environment without DOM api #595

OlegWock opened this issue Feb 28, 2023 · 1 comment · Fixed by #597

Comments

@OlegWock
Copy link
Contributor

Modification Proposal

Expected Behavior / Situation

When executed in environment without window or document (e.g. worker), style loader should not try to inject styles.

Actual Behavior / Situation

Fails with error while trying to access document.createElement

This was already discussed some time ago (#203), but I'm not sure if it was ever resolved. Please let me know if this is something you consider reasonable or if you think it's better to left it as is (raising exception)

I also made a ad-hoc fix for my project (forked this repo and tried to patch it diff), I'm not sure if it's sufficient and covers all cases (I use very basic configuration and patch works with it), but I'm willing to adjust it and make pull request if you find it useful

Please paste the results of npx webpack-cli info here, and mention other relevant information

❯ npx webpack-cli info

  System:
    OS: macOS 13.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 15.86 GB / 64.00 GB
  Binaries:
    Node: 16.18.1 - ~/.nvm/versions/node/v16.18.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.18.1/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.1/bin/npm
  Browsers:
    Brave Browser: 109.1.47.186
    Chrome: 110.0.5481.177
    Firefox: 110.0
    Safari: 16.2
  Packages:
    babel-loader: ^8.2.5 => 8.2.5 
    clean-webpack-plugin: ^4.0.0 => 4.0.0 
    copy-webpack-plugin: ^11.0.0 => 11.0.0 
    css-loader: ^6.7.1 => 6.7.1 
    file-loader: ^6.2.0 => 6.2.0 
    filemanager-webpack-plugin: ^7.0.0 => 7.0.0 
    generate-file-webpack-plugin: ^1.0.1 => 1.0.1 
    moment-timezone-data-webpack-plugin: ^1.5.1 => 1.5.1 
    sass-loader: ^13.0.2 => 13.0.2 
    string-replace-loader: ^3.1.0 => 3.1.0 
    style-loader: git+https://github.com/OlegWock/style-loader => 3.3.1 
    terser-webpack-plugin: ^5.3.3 => 5.3.3 
    to-string-loader: ^1.2.0 => 1.2.0 
    ts-loader: ^9.4.2 => 9.4.2 
    webpack: ^5.75.0 => 5.75.0 
    webpack-bundle-analyzer: ^4.7.0 => 4.7.0 
    webpack-cli: ^5.0.1 => 5.0.1 
@OlegWock OlegWock changed the title Noop in env environment DOM api Noop in environment DOM api Feb 28, 2023
@OlegWock OlegWock changed the title Noop in environment DOM api Noop in environment without DOM api Feb 28, 2023
@alexander-akait
Copy link
Member

alexander-akait commented Mar 7, 2023

Yeah, we should handle that case, do you want to send a PR? Sorry for delay

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