Skip to content

Comments

[FIX] Resolve pathing issues when running mix via php#728

Merged
LukeTowers merged 1 commit intodevelopfrom
mix-compile-path-fix
Oct 7, 2022
Merged

[FIX] Resolve pathing issues when running mix via php#728
LukeTowers merged 1 commit intodevelopfrom
mix-compile-path-fix

Conversation

@jaxwilko
Copy link
Member

@jaxwilko jaxwilko commented Oct 7, 2022

While running the MixCompileTest this error was being thrown for all tests:

ERROR in /tests/fixtures/plugins/mix/testa/assets/dist/app
Module not found: Error: Can't resolve '/var/www/vhosts/winter.com/modules/system/assets/src/app.js' in '/var/www/vhosts/winter.com/modules/system'

After debugging, the issue appeared to be:

mix.js('assets/src/app.js', 'assets/dist/app.js');

resolving to: /var/www/vhosts/winter.com/modules/system/assets/src/app.js

Inside the mix object, the publicPath as being correctly set:

"publicPath": "/var/www/vhosts/winter.com/modules/system/tests/fixtures/plugins/mix/testa",

However, when mix created File objects, the absolute path of the file was being passed to path.resolve() which uses process.cwd(), this should be set by the $cwd arg passed to Process however because process was calling npx instead of the webpack bin directly, the cwd was being overwritten. This lead to:

{
    "js": {
      "passive": false,
      "requiresReload": false,
      "caller": "js",
      "toCompile": [
        {
          "entry": [
            {
              "absolutePath": "/var/www/vhosts/winter.com/modules/system/assets/src/app.js",
              "filePath": "assets/src/app.js",
              "segments": {
                "path": "assets/src/app.js",
                "absolutePath": "/var/www/vhosts/winter.com/modules/system/assets/src/app.js",
                "pathWithoutExt": "/var/www/vhosts/winter.com/modules/system/assets/src/app",
                "isDir": false,
                "isFile": true,
                "name": "app",
                "ext": ".js",
                "file": "app.js",
                "base": "/var/www/vhosts/winter.com/modules/system/assets/src"
              }
            }
          ],
          "output": {
            "absolutePath": "/var/www/vhosts/winter.com/modules/system/assets/dist/app.js",
            "filePath": "assets/dist/app.js",
            "segments": {
              "path": "assets/dist/app.js",
              "absolutePath": "/var/www/vhosts/winter.com/modules/system/assets/dist/app.js",
              "pathWithoutExt": "/var/www/vhosts/winter.com/modules/system/assets/dist/app",
              "isDir": false,
              "isFile": true,
              "name": "app",
              "ext": ".js",
              "file": "app.js",
              "base": "/var/www/vhosts/winter.com/modules/system/assets/dist"
            }
          }
        }
      ],
      "activated": true
    },
}

This PR reverts the change using npx back to calling webpack's bin directly.

Linux host test:
image

Windows host test:
image

@LukeTowers LukeTowers merged commit 4b7b864 into develop Oct 7, 2022
@bennothommo bennothommo added this to the v1.2.1 milestone Oct 8, 2022
@bennothommo bennothommo added Status: Completed maintenance PRs that fix bugs, are translation changes or make only minor changes labels Oct 8, 2022
LukeTowers added a commit that referenced this pull request Oct 24, 2022
…d-themes-luke

* commit '966edea734a0e330f19ebe2547a1332ed39cb907':
  Set pivot data when initially syncing the relationship
  Update jobs tables to support Laravel 9 (#730)
  Add migrate to list of protected commands (#733)
  Add "Send password reset email" button to backend users update page (#723)
  Adjust descriptor for local event
  Change event doc to test new event functionality in Docs plugin
  Removed NPX from webpack bin call (#728)
  Add test case for getParentData method in AJAX framework
  Recompile Snowboard
  Allow for custom AJAX error responses to be passed through handlers
  Allow detached AJAX request to be called with 2 params
  Improve IDE knowledge of the PluginBase object
  Fix support for data-request-parent
LukeTowers added a commit that referenced this pull request Oct 26, 2022
* develop:
  Set pivot data when initially syncing the relationship (#739)
  Added CLI signature to mix:list command
  Fix Navigation Manager unit test
  Update jobs tables to support Laravel 9 (#730)
  Add migrate to list of protected commands (#733)
  Add "Send password reset email" button to backend users update page (#723)
  Adjust descriptor for local event
  Change event doc to test new event functionality in Docs plugin
  Removed NPX from webpack bin call (#728)
  Add test case for getParentData method in AJAX framework
  Recompile Snowboard
  Allow for custom AJAX error responses to be passed through handlers
  Allow detached AJAX request to be called with 2 params
  Improve IDE knowledge of the PluginBase object
  Fix support for data-request-parent
@bennothommo bennothommo deleted the mix-compile-path-fix branch November 2, 2022 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance PRs that fix bugs, are translation changes or make only minor changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants