GithubHelp home page GithubHelp logo

Comments (10)

azu avatar azu commented on May 30, 2024

Thanks for reports.

I try to reproduce it, but I can not reproduce it.

✈ node -v
v8.12.0
~/.ghq/github.com/azu/rc-config-loader-issue-2
✈ cat example.js
const rcfile = require("rc-config-loader");
~/.ghq/github.com/azu/rc-config-loader-issue-2
✈ node example.js

Related:

from rc-config-loader.

azu avatar azu commented on May 30, 2024

I've seen same error(Module not found: Can't resolve 'module') on webpack.

Is this issue related to that?

from rc-config-loader.

ravecat avatar ravecat commented on May 30, 2024

I create branch that reproduce issue

Reproduction

  1. git clone https://github.com/ravecat/mendeleev.git --single-branch --branch rc-config-loader-issue
  2. yarn

I have code in src/common/Media/responsive/index.js

/* eslint-disable */
import { css } from "styled-components";
const rcfile = require("rc-config-loader");

const responsive = (property, resolution) => {
  console.log(rcfile('sct'))

  return css`
    @media (max-width: ${resolution}px) {
      ${property};
    }
  `;
}

export default responsive;

In same folder I also exist .sctrc file

from rc-config-loader.

ravecat avatar ravecat commented on May 30, 2024

I've seen same error(Module not found: Can't resolve 'module') on webpack.

Is this issue related to that?

I need check, probably it's related

from rc-config-loader.

azu avatar azu commented on May 30, 2024

Thanks.

I tried this repository and `yarn test` work fine in my env.
~/.ghq/github.com/azu/testa/mendeleev
$ node -v
v8.12.0
~/.ghq/github.com/azu/testa/mendeleev 
$ yarn -v
1.9.4
$ yarn 
# install..
$ yarn test
 PASS  src/common/Media/responsive/index.test.js
  ● Console
console.log src/common/Media/responsive/index.js:6
  { config: { responsive: [ 1023, 1600 ] },
    filePath: '/Users/azu/.ghq/github.com/azu/testa/mendeleev/.sctrc' }

PASS src/App.test.js
● Console

console.log src/common/Media/responsive/index.js:6
  { config: { responsive: [ 1023, 1600 ] },
    filePath: '/Users/azu/.ghq/github.com/azu/testa/mendeleev/.sctrc' }
console.log src/common/Media/responsive/index.js:6
  { config: { responsive: [ 1023, 1600 ] },
    filePath: '/Users/azu/.ghq/github.com/azu/testa/mendeleev/.sctrc' }
console.log src/common/Media/responsive/index.js:6
  { config: { responsive: [ 1023, 1600 ] },
    filePath: '/Users/azu/.ghq/github.com/azu/testa/mendeleev/.sctrc' }
console.log src/common/Media/responsive/index.js:6
  { config: { responsive: [ 1023, 1600 ] },
    filePath: '/Users/azu/.ghq/github.com/azu/testa/mendeleev/.sctrc' }

Test Suites: 3 passed, 3 total
Tests: 4 passed, 4 total
Snapshots: 0 total
Time: 14.001s
Ran all test suites.

Watch Usage: Press w to show more.

✨ Done in 31.79s.

But, I've confirmed that yarn start is failed.

image

This error is caused by webpack.
Because, webpack can not treat module module.

You can avoid this error with following patch.

diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js
index 36d1767..6da9f84 100644
--- a/config/webpack.config.dev.js
+++ b/config/webpack.config.dev.js
@@ -118,6 +118,7 @@ module.exports = {
   node: {
     dgram: "empty",
     fs: "empty",
+    module: "empty",
     net: "empty",
     tls: "empty",
     child_process: "empty"
diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js
index 047b7f8..5399e97 100644
--- a/config/webpack.config.prod.js
+++ b/config/webpack.config.prod.js
@@ -203,6 +203,7 @@ module.exports = {
   node: {
     dgram: "empty",
     fs: "empty",
+    module: "empty",
     net: "empty",
     tls: "empty",
     child_process: "empty"

I've submitted a PR to fix this issue.

from rc-config-loader.

ravecat avatar ravecat commented on May 30, 2024

@azu thank you very match, I will include your solution in extended functionality!

from rc-config-loader.

azu avatar azu commented on May 30, 2024

No problem.

from rc-config-loader.

ravecat avatar ravecat commented on May 30, 2024

@azu Sorry for interrupt, but I want to clarify some questions

Accorind sources, if I haven't options rc-config-loader use default path for search - current directory

const configFileName = opts.configFileName || `.${pkgName}rc`;

So I use loader without options and get undefined. Code available like previous comment

  1. git clone https://github.com/ravecat/mendeleev.git --single-branch --branch rc-config-loader-issue
  2. yarn

I have code in src/common/Media/helpers/getConfig.js

const rcfile = require("rc-config-loader");

const getConfig = () => {
  console.log(rcfile("sct"));
 
  debugger
  return 
}

export default getConfig

and try to use in src/common/Media/responsive/index.js

import { css } from "styled-components";
import getConfig from '../helpers/getConfig'

const responsive = (property, resolution) => {
  const resolutions = getConfig()

  return css`
    @media (max-width: ${resolution}px) {
      ${property};
    }
  `;
}

export default responsive;

Probably it's again webpack settings relative with resolve options, but I use relative path, not absolute

from rc-config-loader.

azu avatar azu commented on May 30, 2024

Can you create it as new issue?

from rc-config-loader.

ravecat avatar ravecat commented on May 30, 2024

@azu yep, here #3

from rc-config-loader.

Related Issues (8)

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.