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

Doesn't work out of the box with webpack. #138

Open
martin-cowie opened this issue Nov 28, 2018 · 0 comments
Open

Doesn't work out of the box with webpack. #138

martin-cowie opened this issue Nov 28, 2018 · 0 comments

Comments

@martin-cowie
Copy link

Using webpack almost works out of the box.

Steps to repro.

  • npm install --save bigtext
  • require('bigtext') somewhere in the project
  • webpack a bundle and get this output...
      looking for modules in /Users/martincowie/Development/Diffusion/Main/javascript/console/node_modules
        using description file: /Users/martincowie/Development/Diffusion/Main/javascript/console/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
          using description file: /Users/martincowie/Development/Diffusion/Main/javascript/console/node_modules/bigtext/package.json (relative path: .)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/martincowie/Development/Diffusion/Main/javascript/console/node_modules/bigtext is not a file
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/martincowie/Development/Diffusion/Main/javascript/console/node_modules/bigtext.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/martincowie/Development/Diffusion/Main/javascript/console/node_modules/bigtext.js doesn't exist
            as directory
              existing directory
                using path: /Users/martincowie/Development/Diffusion/Main/javascript/console/node_modules/bigtext/index
                  using description file: /Users/martincowie/Development/Diffusion/Main/javascript/console/node_modules/bigtext/package.json (relative path: ./index)
                    no extension
                      Field 'browser' doesn't contain a valid alias configuration
                      /Users/martincowie/Development/Diffusion/Main/javascript/console/node_modules/bigtext/index doesn't exist
                    .ts
                      Field 'browser' doesn't contain a valid alias configuration
                      /Users/martincowie/Development/Diffusion/Main/javascript/console/node_modules/bigtext/index.ts doesn't exist
                    .js
                      Field 'browser' doesn't contain a valid alias configuration
                      /Users/martincowie/Development/Diffusion/Main/javascript/console/node_modules/bigtext/index.js doesn't exist

Essentially webpack is looking in the wrong place, where it should be looking for ./dist/bigtext.js. Setting browser in package.json to dist/bigtext.js will resolve the problem.

As a workaround I have configured my webpack config thus ...

...
  resolve: {
    extensions: ['.ts', '.js' ],
    alias: {
        bigtext: "bigtext/dist/bigtext.js"
    }
  }
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

1 participant