falsandtru / pjax-api

The advanced PJAX superior to SPA.
https://falsandtru.github.io/pjax-api/
Apache License 2.0
318 stars 28 forks source link

Work with laravel 5.3 and webpack. #22

Closed chivincent closed 7 years ago

chivincent commented 7 years ago

Hello, I got an error when using this package in Laravel 5.3 and webpack.

First, I installed the package from npm:

npm install pjax-api spica localsocket

Second, I wrote the script file which should be compiled by webpack.

import Pjax from 'pjax-api';

new Pjax({
    areas: ['body']
});

However, I got an error when compile the file by webpack.

{ [Error: ./~/pjax-api/dist/pjax-api.js
Module not found: Error: Can't resolve './src/import' in '/Volumes/Data/Laravel/test/node_modules/pjax-api/dist'
resolve './src/import' in '/Volumes/Data/Laravel/test/node_modules/pjax-api/dist'
  using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./dist)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./dist)
    using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./dist/src/import)
      as directory
        /Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import doesn't exist
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import.json doesn't exist
[/Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import]
[/Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import]
[/Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import.js]
[/Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import.json]
 @ ./~/pjax-api/dist/pjax-api.js 2084:0-2099:2
 @ ./resources/assets/js/app.js./~/pjax-api/dist/pjax-api.js
Module not found: Error: Can't resolve '../service/state/scroll-restoration' in '/Volumes/Data/Laravel/test/node_modules/pjax-api/dist'
resolve '../service/state/scroll-restoration' in '/Volumes/Data/Laravel/test/node_modules/pjax-api/dist'
  using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./dist)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./dist)
    using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./service/state/scroll-restoration)
      as directory
        /Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration doesn't exist
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration.json doesn't exist
[/Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration]
[/Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration]
[/Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration.js]
[/Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration.json]
 @ ./~/pjax-api/dist/pjax-api.js 1890:0-2065:2
 @ ./resources/assets/js/app.js./~/localsocket/dist/localsocket.js
Module not found: Error: Can't resolve './index' in '/Volumes/Data/Laravel/test/node_modules/localsocket/dist'
resolve './index' in '/Volumes/Data/Laravel/test/node_modules/localsocket/dist'
  using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist)
    using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist/index)
      as directory
        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/index doesn't exist
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/index doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/index.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/index.json doesn't exist
[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/index]
[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/index]
[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/index.js]
[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/index.json]
 @ ./~/localsocket/dist/localsocket.js 2359:0-2375:2
 @ ./~/pjax-api/dist/pjax-api.js
 @ ./resources/assets/js/app.js./~/spica/dist/spica.js
Module not found: Error: Can't resolve './src/import' in '/Volumes/Data/Laravel/test/node_modules/spica/dist'
resolve './src/import' in '/Volumes/Data/Laravel/test/node_modules/spica/dist'
  using description file: /Volumes/Data/Laravel/test/node_modules/spica/package.json (relative path: ./dist)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Volumes/Data/Laravel/test/node_modules/spica/package.json (relative path: ./dist)
    using description file: /Volumes/Data/Laravel/test/node_modules/spica/package.json (relative path: ./dist/src/import)
      as directory
        /Volumes/Data/Laravel/test/node_modules/spica/dist/src/import doesn't exist
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/spica/dist/src/import doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/spica/dist/src/import.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/spica/dist/src/import.json doesn't exist
[/Volumes/Data/Laravel/test/node_modules/spica/dist/src/import]
[/Volumes/Data/Laravel/test/node_modules/spica/dist/src/import]
[/Volumes/Data/Laravel/test/node_modules/spica/dist/src/import.js]
[/Volumes/Data/Laravel/test/node_modules/spica/dist/src/import.json]
 @ ./~/spica/dist/spica.js 3233:0-3246:2
 @ ./~/pjax-api/dist/pjax-api.js
 @ ./resources/assets/js/app.js./~/localsocket/dist/localsocket.js
Module not found: Error: Can't resolve './src/import' in '/Volumes/Data/Laravel/test/node_modules/localsocket/dist'
resolve './src/import' in '/Volumes/Data/Laravel/test/node_modules/localsocket/dist'
  using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist)
    using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist/src/import)
      as directory
        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import doesn't exist
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import.json doesn't exist
[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import]
[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import]
[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import.js]
[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import.json]
 @ ./~/localsocket/dist/localsocket.js 2359:0-2375:2
 @ ./~/pjax-api/dist/pjax-api.js
 @ ./resources/assets/js/app.js]
  message: './~/pjax-api/dist/pjax-api.js\nModule not found: Error: Can\'t resolve \'./src/import\' in \'/Volumes/Data/Laravel/test/node_modules/pjax-api/dist\'\nresolve \'./src/import\' in \'/Volumes/Data/Laravel/test/node_modules/pjax-api/dist\'\n  using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./dist)\n    Field \'browser\' doesn\'t contain a valid alias configuration\n  after using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./dist)\n    using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./dist/src/import)\n      as directory\n        /Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import doesn\'t exist\n      no extension\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import doesn\'t exist\n      .js\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import.js doesn\'t exist\n      .json\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import.json doesn\'t exist\n[/Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import]\n[/Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import]\n[/Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import.js]\n[/Volumes/Data/Laravel/test/node_modules/pjax-api/dist/src/import.json]\n @ ./~/pjax-api/dist/pjax-api.js 2084:0-2099:2\n @ ./resources/assets/js/app.js./~/pjax-api/dist/pjax-api.js\nModule not found: Error: Can\'t resolve \'../service/state/scroll-restoration\' in \'/Volumes/Data/Laravel/test/node_modules/pjax-api/dist\'\nresolve \'../service/state/scroll-restoration\' in \'/Volumes/Data/Laravel/test/node_modules/pjax-api/dist\'\n  using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./dist)\n    Field \'browser\' doesn\'t contain a valid alias configuration\n  after using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./dist)\n    using description file: /Volumes/Data/Laravel/test/node_modules/pjax-api/package.json (relative path: ./service/state/scroll-restoration)\n      as directory\n        /Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration doesn\'t exist\n      no extension\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration doesn\'t exist\n      .js\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration.js doesn\'t exist\n      .json\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration.json doesn\'t exist\n[/Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration]\n[/Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration]\n[/Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration.js]\n[/Volumes/Data/Laravel/test/node_modules/pjax-api/service/state/scroll-restoration.json]\n @ ./~/pjax-api/dist/pjax-api.js 1890:0-2065:2\n @ ./resources/assets/js/app.js./~/localsocket/dist/localsocket.js\nModule not found: Error: Can\'t resolve \'./index\' in \'/Volumes/Data/Laravel/test/node_modules/localsocket/dist\'\nresolve \'./index\' in \'/Volumes/Data/Laravel/test/node_modules/localsocket/dist\'\n  using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist)\n    Field \'browser\' doesn\'t contain a valid alias configuration\n  after using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist)\n    using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist/index)\n      as directory\n        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/index doesn\'t exist\n      no extension\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/index doesn\'t exist\n      .js\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/index.js doesn\'t exist\n      .json\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/index.json doesn\'t exist\n[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/index]\n[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/index]\n[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/index.js]\n[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/index.json]\n @ ./~/localsocket/dist/localsocket.js 2359:0-2375:2\n @ ./~/pjax-api/dist/pjax-api.js\n @ ./resources/assets/js/app.js./~/spica/dist/spica.js\nModule not found: Error: Can\'t resolve \'./src/import\' in \'/Volumes/Data/Laravel/test/node_modules/spica/dist\'\nresolve \'./src/import\' in \'/Volumes/Data/Laravel/test/node_modules/spica/dist\'\n  using description file: /Volumes/Data/Laravel/test/node_modules/spica/package.json (relative path: ./dist)\n    Field \'browser\' doesn\'t contain a valid alias configuration\n  after using description file: /Volumes/Data/Laravel/test/node_modules/spica/package.json (relative path: ./dist)\n    using description file: /Volumes/Data/Laravel/test/node_modules/spica/package.json (relative path: ./dist/src/import)\n      as directory\n        /Volumes/Data/Laravel/test/node_modules/spica/dist/src/import doesn\'t exist\n      no extension\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/spica/dist/src/import doesn\'t exist\n      .js\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/spica/dist/src/import.js doesn\'t exist\n      .json\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/spica/dist/src/import.json doesn\'t exist\n[/Volumes/Data/Laravel/test/node_modules/spica/dist/src/import]\n[/Volumes/Data/Laravel/test/node_modules/spica/dist/src/import]\n[/Volumes/Data/Laravel/test/node_modules/spica/dist/src/import.js]\n[/Volumes/Data/Laravel/test/node_modules/spica/dist/src/import.json]\n @ ./~/spica/dist/spica.js 3233:0-3246:2\n @ ./~/pjax-api/dist/pjax-api.js\n @ ./resources/assets/js/app.js./~/localsocket/dist/localsocket.js\nModule not found: Error: Can\'t resolve \'./src/import\' in \'/Volumes/Data/Laravel/test/node_modules/localsocket/dist\'\nresolve \'./src/import\' in \'/Volumes/Data/Laravel/test/node_modules/localsocket/dist\'\n  using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist)\n    Field \'browser\' doesn\'t contain a valid alias configuration\n  after using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist)\n    using description file: /Volumes/Data/Laravel/test/node_modules/localsocket/package.json (relative path: ./dist/src/import)\n      as directory\n        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import doesn\'t exist\n      no extension\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import doesn\'t exist\n      .js\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import.js doesn\'t exist\n      .json\n        Field \'browser\' doesn\'t contain a valid alias configuration\n        /Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import.json doesn\'t exist\n[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import]\n[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import]\n[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import.js]\n[/Volumes/Data/Laravel/test/node_modules/localsocket/dist/src/import.json]\n @ ./~/localsocket/dist/localsocket.js 2359:0-2375:2\n @ ./~/pjax-api/dist/pjax-api.js\n @ ./resources/assets/js/app.js',
  showStack: false,
  showProperties: true,
  plugin: 'webpack-stream',
  __safety: { toString: [Function: bound ] } }
falsandtru commented 7 years ago

Hi, I don't know webpack, This and depended libraries provide endpoints of global variable such as pjax-api, localsocket, and spica. Can you resolve these dependencies like other libraries?

chivincent commented 7 years ago

OK, I'll try it as soon as possible. Thanks for your response. :)