madyankin / madyankin/postcss-modules

Make this package browser friendly

Open
#132 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.6k
Forks
88
PR merge metrics
No merged PRs in 30d

Description

Hello we have a use case that we want to use this plugin in the browser and bundle it via webpack.
Currently the FileSystemLoader is being use as a fallback loader if no load provided via the config, and it is always imported by the package index.

The issue is:
FileSystemLoader imports nodejs fs module and that's not browser friendly (needs config in order to bundle).

I have few suggestions for solutions to this issue:

  1. Add "browser" field to the package.json that will implement a "loader" that throws something like "when using this package in browser you must provide a custom loader"
  2. Create entrypoint specifically for browser usage which does not import FileSystemLoader by default
  3. Allow inject the fs module to the loaders avoiding importing it directly (split the index into a factory that will accept fs)

These are non-breaking changes that can be done here.

We are willing to make this PR.

Please advice.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the package index and FileSystemLoader, then inspect package.json and reproduce the webpack bundle issue caused by importing Node.js fs. Compare the proposed browser field, browser entry point, and injected fs approaches; done means browser consumers can bundle the package with a custom loader without requiring fs configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, webpack
Domain
build-system, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.