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

webpack v5 error when module contains dynamic import: "Automatic publicPath is not supported in this browser" #18435

Closed
OliverJAsh opened this issue Oct 11, 2021 · 15 comments · Fixed by #23760

Comments

@OliverJAsh
Copy link
Contributor

OliverJAsh commented Oct 11, 2021

Current behavior

When using webpack v5 and a test contains a dynamic import (or imports a module that contains a dynamic import) the test will fail with the following error: Automatic publicPath is not supported in this browser.

  Running:  example.test.js                                                                 (1 of 1)


  1) An uncaught error was detected outside of a test

  0 passing (214ms)
  1 failing

  1) An uncaught error was detected outside of a test:
     Error: The following error originated from your test code, not from Cypress.

  > Automatic publicPath is not supported in this browser

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.
      at eval (http://localhost:61013/__cypress/tests?p=cypress/integration/example.test.js:155:34)
      at eval (http://localhost:61013/__cypress/tests?p=cypress/integration/example.test.js:158:13)
      at eval (http://localhost:61013/__cypress/tests?p=cypress/integration/example.test.js:261:12)
      at eval (<anonymous>)

Desired behavior

No error.

Test code to reproduce

Full reduced test case: https://github.com/OliverJAsh/cypress-webpack-5-public-path-error

This might seem like a contrived example because I have reduced it down from a much larger use case.

cypress/integration/lazy.js:

export const a = 1;

cypress/integration/example.test.js:

() => import('./lazy');

describe("foo", () => {
    it("works", () => {});
});

cypress/plugins/index.js:

const webpackPreprocessor = require("@cypress/webpack-preprocessor");

module.exports = (on, config) => {
    on(
        "file:preprocessor",
        webpackPreprocessor({
            webpackOptions: {},
        })
    );
};

cypress.json:

{}

package.json:

{
  "dependencies": {
    "@cypress/webpack-preprocessor": "^5.9.1",
    "cypress": "^8.5.0",
    "webpack": "^5.58.1"
  }
}

Cypress Version

8.5.0

Other

I was able to workaround the error by setting publicPath: '' inside of here:

I'm not really sure I understand why this issue happens nor how this fixes the issue, but FWIW this fix was recommended here: https://stackoverflow.com/questions/64294706/webpack5-automatic-publicpath-is-not-supported-in-this-browser?rq=1.

The issue does not reproduce when using webpack v4.

@marleau
Copy link

marleau commented Nov 8, 2021

I am experiencing the same issue. The workaround provided works for me.

@thril
Copy link

thril commented Nov 17, 2021

While it works (locally), modifying node_modules directly as a workaround is not reasonable or long term solution, especially since we can't do this as part of our automated CI process. Can we get some eyes/priority/status on this issue since it's a blocker for part of our test suite? Thanks.

@thril
Copy link

thril commented Nov 17, 2021

Well since I wrote my comment an hour ago, I found a longer term workaround until a more permanent solution is provided that doesn't involve manually modifying the webpack-preprocessor. I modified the inline webpack config for my file:preprocessor by adding mini-css-extract-plugin.

const wp = require("@cypress/webpack-preprocessor");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const webpackOptions = {
  devtool: false,
  ...
  plugins: [new MiniCssExtractPlugin()],
  module: {
    rules: [
      ...
      {
        test: /\.css$/,
        use: [
          "style-loader",
          {
            loader: MiniCssExtractPlugin.loader,
            options: {
              esModule: false,
              publicPath: "",
            },
          },
          "css-loader",
        ],
      },
    ],
  },
};

const options = {
  webpackOptions,
};

module.exports = wp(options);

@BlueWinds
Copy link
Contributor

Thanks for the report and detailed investigation, webpack errors are always hard to track down.

The change to @cypress/webpack-preprocessor looks fairly straightforward, if anyone wants to submit a PR we'd be happy to review and get it in. Otherwise, I've added this to our list to discuss, but can't promise when the team will get around to a fix, especially since @thril has provided a working / less hacky solution.

@shahzaibkhalid
Copy link

Is there any update on this? Seems like it's breaking even when I'm not using mini-css-extract-plugin.

ohrie added a commit to FixMyBerlin/fixmy.frontend that referenced this issue Jan 18, 2022
Cypress tests are not working after upgrading to webpack 5

Reenable after bug is fixed by Cypress.

See cypress-io/cypress#18435
@emilyrohrbough
Copy link
Member

#18748 was logged with the same issue.

ohrie added a commit to FixMyBerlin/fixmy.frontend that referenced this issue Feb 10, 2022
* Remove querystring dependencies (#925)

* Remove query-string dependecy

* Remove qs dependency and replace with URLSearchParams

* Remove obsolet implicit boolean conversion

* Add hover support for clickable features for 'plaungen'& 'zustand' | Ref #929

* Rename BMVI to BMDV (#935)

* Rename BMVI to BMDV

Add SVG editions of new Logo

* Replace SVG Logo through PNG BMDV

* Dependency cleanup and updates (#912)

* Remove unused babel plugins

* Remove unused packages

* Update NodeJS types

* Update package-lock

* Update and fix storybook

Dependency @material-ui/styles was missing

* Add ts-expect-error

* Update dev tools

* Migrate webpack config

* Migrate eslint config

* Linter error fixes

* Linter warning fixes

* Remove common-tags

* Fix browserslist

* Remove ads during npm install

* Update manifest background color

* Update webpack and other devtools + config

* Disable ts error

* Update eslint

* Don't require babel config file

* Comment oiut empty transform ignore patterns

* Fix unit tests

* Update linter

* Update core-js version for babel/preset-env

* Try running linter directly

* Remove unused dep

* Remove unused function

* Apply linter fixes

* Dep updates

* Fix incompatible dependencies

* Remove custom Jest tsconfig

(which caused errors during test runs)

* Re-enable Eslint cache

* Update react-markdown syntax

* Fix reselect type

* Fix getCenterFromGeom for point geometries

* Remove buggy report edit button

* Transpile Typescript only in dev server

* Apply linter fixes

* Remove dead code

* Apply linter fixes

* Update jest.config.js

Extend the help comment based on https://github.com/FixMyBerlin/fixmy.frontend/pull/912/files/143fe21a799af88cf8f5f0c9bf52829ed61fd460#r784012274

* Turn on function component eslint rule with arrow functions

Co-authored-by: Tobias <tobias@fixmycity.de>
Co-authored-by: Henri <henri@fixmycity.de>

* Disable Cypress integration tests for now

Cypress tests are not working after upgrading to webpack 5

Reenable after bug is fixed by Cypress.

See cypress-io/cypress#18435

* Docs comments lint small fixes (#951)

* Readme: Add link to todenv

* Gastro: Re-activate the gastro app on staging for testing

* Map: Add comment about release-system

* Remove false empty space in URL

* CSS: Fix Links styles

- white space none was overwritten to pre-wrap below.
- padding none is invalid, should be 0.

* Comment breakpoints

* Document Dotenv

* Update mui-utils.ts

```
createTheme.js?2bfd:94 Material-UI: the createMuiTheme function was renamed to createTheme.

You should use `import { createTheme } from '@material-ui/core/styles'
`
``

* Remove popupbikelanes map and route (#952)

* Remove and redirect /popupbikelanes Map

Those are part of the regular planning view, now.

* Remove /popupbikelanes Routes

* Add `.editorconfig` and `.vscode` files (#947)

* Add `.editorconfig` and `.vscode` files

Start streamlining editor settings.

* Add styled component recommended extension

* .vscode/settings: Remove organizeImports

This does not work great. It deletes imports too early, eg when there is an error in your code formatting or a snipped is commented out for testing. We have to do this manually per file, for now.

Co-authored-by: Henri <henri@fixmycity.de>

* eslint config: Remove import order rules (#950)

I suggest we remove this rule and instead rely on VS Codes "Organize Imports" which can be done on save https://eshlox.net/2019/12/02/vscode-automatically-organize-typescript-imports/

* Xhain: Fix last name & update official status (#949)

"HerRmann"

She is no longer the mayor of Friedrichshain-Kreuzberg and uses "Ex-" in front of her former job title for herself now (Eg. Twitter).

* Improve mouse hover map (#936)

* Integrate improvements for map events for hovering by @tordans

* Add pointer cursor for marker images

* Refactor registerMouseHoverHandler

Co-authored-by: Tobias <tobias@fixmycity.de>

* HBI: Add WelcomeModal, update HBI-FAQ (#946)

* Use Link component for FAQ

Which styles them is the right way.

* Update FAQ with content about current HBI

* WebglMap: Extract map/indexView into Component state

* Introduce WelcomModal on WebglMap

Use URL schema `/zustand?lat=50.1&lng=10&zoom=10` to set the map, which is a hidden feature.

* Extract ModalCloseIcon into Component

* WelcomeModal: Fix `aria-*` attributes

- Document aria-controls
- Fix cut off border in SVG with overflow styles; also css width is better than attribute width
- Add Modal-aria-attributes

* Remove 'beta' from Logo

* HBI: Refactor WelcomeModal, Fix Links in Modal, Fix Overlay-Layer visibility (#954)

* WelcomeModal: Extract styles in separate file

* WelcomeModal: Split Components, Fix Column2 Center/Zoom

- Center/Zoom for Column2 does not reload the page anymore, so the closed-State of the modal is preserved.
- Column1 still has a reload, though. But this is less annoying.
- Columns are split into Components to keep the Modal Component small.

* Map: Bugfix: Overlay layers where not filtered properly

Fixes #934

* Upgrade to styled-components v5 (#961)

* Fix loading images from Markdown pages (#964)

* Fix loading images from Markdown pages

* Upgrade react-markdown to 8.0.0

* Readd require.context for images, so image is available in build

* Bump node-fetch from 2.6.6 to 2.6.7 (#962)

Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.6 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](node-fetch/node-fetch@v2.6.6...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add search icon to search bar (#955)

* Add search icon to search bar

* Reverse if logic

* Resolve PR threads -> SearchIcon

* Use SVG as inline component and not background-image

* Upgrade msw to 0.36.7 (#965)

* Update version to 1.1.0

* Add map legend hbi (#960)

* Add first static MapLegend for accidents & cadastre

* Add individual legend components

* Map Legend toggle working with button

* Add Link & Hint to Legend

* Add correct Incidient legend items with POints

* Fix styling for bottom link/text in MapLegend

* Fixed different Header style in Flexbox

* Fix linter issues

* Use React hooks as imported functions

The pattern I suggest is, to import React hook `React.use*` directly. But use `React.FC` and such when using React-Types.

* Create Component ModalCloseIcon

Move the local component to be a full component in our components2 folder.
Use it for the Kataster legend.

This fixes an issue, that the border lines of the close-icon are cut off.

* Fix fill color for Kataster legend

The gray of the outline was lighter than the gray of the location icon below due to this svg filter stuff.

* Horizontal navigation bar (#953)

* Rename MapLegend to MapSelectorBar & rudimentary Selector Bar functionality

Reduce misunderstandings

* Fix margin in MapSelectorBar in default mode

* Docs comments lint small fixes (#951)

* Readme: Add link to todenv

* Gastro: Re-activate the gastro app on staging for testing

* Map: Add comment about release-system

* Remove false empty space in URL

* CSS: Fix Links styles

- white space none was overwritten to pre-wrap below.
- padding none is invalid, should be 0.

* Comment breakpoints

* Document Dotenv

* Update mui-utils.ts

```
createTheme.js?2bfd:94 Material-UI: the createMuiTheme function was renamed to createTheme.

You should use `import { createTheme } from '@material-ui/core/styles'
`
``

* Remove popupbikelanes map and route (#952)

* Remove and redirect /popupbikelanes Map

Those are part of the regular planning view, now.

* Remove /popupbikelanes Routes

* Add `.editorconfig` and `.vscode` files (#947)

* Add `.editorconfig` and `.vscode` files

Start streamlining editor settings.

* Add styled component recommended extension

* .vscode/settings: Remove organizeImports

This does not work great. It deletes imports too early, eg when there is an error in your code formatting or a snipped is commented out for testing. We have to do this manually per file, for now.

Co-authored-by: Henri <henri@fixmycity.de>

* eslint config: Remove import order rules (#950)

I suggest we remove this rule and instead rely on VS Codes "Organize Imports" which can be done on save https://eshlox.net/2019/12/02/vscode-automatically-organize-typescript-imports/

* Xhain: Fix last name & update official status (#949)

"HerRmann"

She is no longer the mayor of Friedrichshain-Kreuzberg and uses "Ex-" in front of her former job title for herself now (Eg. Twitter).

* Improve mouse hover map (#936)

* Integrate improvements for map events for hovering by @tordans

* Add pointer cursor for marker images

* Refactor registerMouseHoverHandler

Co-authored-by: Tobias <tobias@fixmycity.de>

* HBI: Add WelcomeModal, update HBI-FAQ (#946)

* Use Link component for FAQ

Which styles them is the right way.

* Update FAQ with content about current HBI

* WebglMap: Extract map/indexView into Component state

* Introduce WelcomModal on WebglMap

Use URL schema `/zustand?lat=50.1&lng=10&zoom=10` to set the map, which is a hidden feature.

* Extract ModalCloseIcon into Component

* WelcomeModal: Fix `aria-*` attributes

- Document aria-controls
- Fix cut off border in SVG with overflow styles; also css width is better than attribute width
- Add Modal-aria-attributes

* Remove 'beta' from Logo

* Improve MapSelectorBar & SVG file using new alignment system

Now the MapSelectorBar is perfectly horizontal on Desktop and vertical on mobile

* Fix MapSelectorBar for embed mode

* Fix prettier warnings.

* Disable MapLegend for now

* Improve SVG sizes for braces

* Resolve obsolete display: block

* Remove test for MapLegend

* Fix problems mentioned in PR

* HBI: Refactor WelcomeModal, Fix Links in Modal, Fix Overlay-Layer visibility (#954)

* WelcomeModal: Extract styles in separate file

* WelcomeModal: Split Components, Fix Column2 Center/Zoom

- Center/Zoom for Column2 does not reload the page anymore, so the closed-State of the modal is preserved.
- Column1 still has a reload, though. But this is less annoying.
- Columns are split into Components to keep the Modal Component small.

* Map: Bugfix: Overlay layers where not filtered properly

Fixes #934

* Add individual legend components

* Map Legend toggle working with button

* Add Link & Hint to Legend

* Add correct Incidient legend items with POints

* Fix styling for bottom link/text in MapLegend

* Fixed different Header style in Flexbox

* Fix linter issues

* Upgrade to styled-components v5 (#961)

* Use React hooks as imported functions

The pattern I suggest is, to import React hook `React.use*` directly. But use `React.FC` and such when using React-Types.

* Create Component ModalCloseIcon

Move the local component to be a full component in our components2 folder.
Use it for the Kataster legend.

This fixes an issue, that the border lines of the close-icon are cut off.

* Fix fill color for Kataster legend

The gray of the outline was lighter than the gray of the location icon below due to this svg filter stuff.

* Set fixed width for MapSwitchWrapper

* Readd MapLegend to correspond to target branch

* Rename MapLegend to MapSelectorBar & rudimentary Selector Bar functionality

Reduce misunderstandings

* Fix margin in MapSelectorBar in default mode

* Improve MapSelectorBar & SVG file using new alignment system

Now the MapSelectorBar is perfectly horizontal on Desktop and vertical on mobile

* Fix MapSelectorBar for embed mode

* Fix prettier warnings.

* Improve SVG sizes for braces

* Resolve obsolete display: block

* Fix problems mentioned in PR

* Set fixed width for MapSwitchWrapper

Co-authored-by: Tobias <tobias@fixmycity.de>
Co-authored-by: Niklas S <75360839+njklas@users.noreply.github.com>

* Improve imports & exports through barrel file

* Improve handling of props and their types

* Map Legend button toggles Legend now

* Moved MapLegend component to legacy components/ folder

Moved images & icons into assets folder

* Fix maplegend color

* Improved spacings of headlines

* Remove StyledCloseIcon & fix z-index failure for WelcomeModal

* Fix more z-index issues & fix mobile view width

Close Icon was not visible on small device

* Fix position of points in legend

* Improve lengths for Legend

Co-authored-by: Tobias <tobias@fixmycity.de>
Co-authored-by: Niklas S <75360839+njklas@users.noreply.github.com>

* Fix Legend height on mobile

* Remove storybook dependencies

* Disable storybook -> temporarily disable Lint issues

* Implement fixes and improvements for HBI 2.0

Squashed commit of the following:

commit acad9b845194a9c66967138b2e0624dc45d2948e
Merge: beaa887c f7d9577
Author: Henri <henri@fixmycity.de>
Date:   Thu Feb 10 11:49:12 2022 +0100

    Merge branch 'develop' into improve-hbi-refresh

commit beaa887c1ad4dd1a505e1d874e5e19f8efb53478
Author: Henri <henri@fixmycity.de>
Date:   Thu Feb 10 11:48:34 2022 +0100

    Update npm packages (lock file)

commit f739cfb
Author: Henri <henri@fixmycity.de>
Date:   Thu Feb 10 11:43:09 2022 +0100

    Fix test config in package.json again

commit 58b3dcb
Author: Henri <henri@fixmycity.de>
Date:   Thu Feb 10 11:38:17 2022 +0100

    Fix tests for HBI interpolation zoom

commit f66b6dc
Author: Henri <henri@fixmycity.de>
Date:   Wed Feb 9 11:19:14 2022 +0100

    Improve Mail in WelcomeModal using AnchorLink component

commit f1c8603
Author: Henri <henri@fixmycity.de>
Date:   Wed Feb 9 11:18:50 2022 +0100

    Fix Close Icon & on focus

    xlink:href is deprecated: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href

commit 533e613
Author: Henri <henri@fixmycity.de>
Date:   Wed Feb 9 10:53:37 2022 +0100

    Optimize maplegend icon activated in size

commit 578a4e0
Author: Henri <henri@fixmycity.de>
Date:   Wed Feb 9 10:40:13 2022 +0100

    Fix planning filters for changing visibility of tracks

commit dba8bb7
Author: Henri <henri@fixmycity.de>
Date:   Tue Feb 8 11:49:04 2022 +0100

    Fix visibility of layers on high zoom / adapt to Mapbox Studio style

commit f352018
Author: Henri <henri@fixmycity.de>
Date:   Mon Feb 7 09:51:47 2022 +0100

    Add active state of map legend icon

commit 15671c7
Author: Henri <henri@fixmycity.de>
Date:   Mon Feb 7 09:44:43 2022 +0100

    Hide Legend Close Icon on Desktop

commit a5b03f0
Author: Henri <henri@fixmycity.de>
Date:   Mon Feb 7 09:33:22 2022 +0100

    Bump up required npm version because of changed lock file version in npm@8

commit e77533b
Author: Henri <henri@fixmycity.de>
Date:   Mon Feb 7 09:31:41 2022 +0100

    Fix text in WelcomModale

* Fix mapbox style url property key issue

The mapbox style urls have been passed through property called "style", which is defined by react for CSS styling. Therefore the string was incorrectly transformed into an object

Changing this to a more specific property key, this resolves the issue.

Co-authored-by: Vincent Ahrend <mail@vincentahrend.com>
Co-authored-by: Tobias <tobias@fixmycity.de>
Co-authored-by: Niklas S <75360839+njklas@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
ohrie added a commit to FixMyBerlin/fixmy.frontend that referenced this issue Feb 16, 2022
* Remove querystring dependencies (#925)

* Remove query-string dependecy

* Remove qs dependency and replace with URLSearchParams

* Remove obsolet implicit boolean conversion

* Add hover support for clickable features for 'plaungen'& 'zustand' | Ref #929

* Rename BMVI to BMDV (#935)

* Rename BMVI to BMDV

Add SVG editions of new Logo

* Replace SVG Logo through PNG BMDV

* Dependency cleanup and updates (#912)

* Remove unused babel plugins

* Remove unused packages

* Update NodeJS types

* Update package-lock

* Update and fix storybook

Dependency @material-ui/styles was missing

* Add ts-expect-error

* Update dev tools

* Migrate webpack config

* Migrate eslint config

* Linter error fixes

* Linter warning fixes

* Remove common-tags

* Fix browserslist

* Remove ads during npm install

* Update manifest background color

* Update webpack and other devtools + config

* Disable ts error

* Update eslint

* Don't require babel config file

* Comment oiut empty transform ignore patterns

* Fix unit tests

* Update linter

* Update core-js version for babel/preset-env

* Try running linter directly

* Remove unused dep

* Remove unused function

* Apply linter fixes

* Dep updates

* Fix incompatible dependencies

* Remove custom Jest tsconfig

(which caused errors during test runs)

* Re-enable Eslint cache

* Update react-markdown syntax

* Fix reselect type

* Fix getCenterFromGeom for point geometries

* Remove buggy report edit button

* Transpile Typescript only in dev server

* Apply linter fixes

* Remove dead code

* Apply linter fixes

* Update jest.config.js

Extend the help comment based on https://github.com/FixMyBerlin/fixmy.frontend/pull/912/files/143fe21a799af88cf8f5f0c9bf52829ed61fd460#r784012274

* Turn on function component eslint rule with arrow functions

Co-authored-by: Tobias <tobias@fixmycity.de>
Co-authored-by: Henri <henri@fixmycity.de>

* Disable Cypress integration tests for now

Cypress tests are not working after upgrading to webpack 5

Reenable after bug is fixed by Cypress.

See cypress-io/cypress#18435

* Docs comments lint small fixes (#951)

* Readme: Add link to todenv

* Gastro: Re-activate the gastro app on staging for testing

* Map: Add comment about release-system

* Remove false empty space in URL

* CSS: Fix Links styles

- white space none was overwritten to pre-wrap below.
- padding none is invalid, should be 0.

* Comment breakpoints

* Document Dotenv

* Update mui-utils.ts

```
createTheme.js?2bfd:94 Material-UI: the createMuiTheme function was renamed to createTheme.

You should use `import { createTheme } from '@material-ui/core/styles'
`
``

* Remove popupbikelanes map and route (#952)

* Remove and redirect /popupbikelanes Map

Those are part of the regular planning view, now.

* Remove /popupbikelanes Routes

* Add `.editorconfig` and `.vscode` files (#947)

* Add `.editorconfig` and `.vscode` files

Start streamlining editor settings.

* Add styled component recommended extension

* .vscode/settings: Remove organizeImports

This does not work great. It deletes imports too early, eg when there is an error in your code formatting or a snipped is commented out for testing. We have to do this manually per file, for now.

Co-authored-by: Henri <henri@fixmycity.de>

* eslint config: Remove import order rules (#950)

I suggest we remove this rule and instead rely on VS Codes "Organize Imports" which can be done on save https://eshlox.net/2019/12/02/vscode-automatically-organize-typescript-imports/

* Xhain: Fix last name & update official status (#949)

"HerRmann"

She is no longer the mayor of Friedrichshain-Kreuzberg and uses "Ex-" in front of her former job title for herself now (Eg. Twitter).

* Improve mouse hover map (#936)

* Integrate improvements for map events for hovering by @tordans

* Add pointer cursor for marker images

* Refactor registerMouseHoverHandler

Co-authored-by: Tobias <tobias@fixmycity.de>

* HBI: Add WelcomeModal, update HBI-FAQ (#946)

* Use Link component for FAQ

Which styles them is the right way.

* Update FAQ with content about current HBI

* WebglMap: Extract map/indexView into Component state

* Introduce WelcomModal on WebglMap

Use URL schema `/zustand?lat=50.1&lng=10&zoom=10` to set the map, which is a hidden feature.

* Extract ModalCloseIcon into Component

* WelcomeModal: Fix `aria-*` attributes

- Document aria-controls
- Fix cut off border in SVG with overflow styles; also css width is better than attribute width
- Add Modal-aria-attributes

* Remove 'beta' from Logo

* HBI: Refactor WelcomeModal, Fix Links in Modal, Fix Overlay-Layer visibility (#954)

* WelcomeModal: Extract styles in separate file

* WelcomeModal: Split Components, Fix Column2 Center/Zoom

- Center/Zoom for Column2 does not reload the page anymore, so the closed-State of the modal is preserved.
- Column1 still has a reload, though. But this is less annoying.
- Columns are split into Components to keep the Modal Component small.

* Map: Bugfix: Overlay layers where not filtered properly

Fixes #934

* Upgrade to styled-components v5 (#961)

* Fix loading images from Markdown pages (#964)

* Fix loading images from Markdown pages

* Upgrade react-markdown to 8.0.0

* Readd require.context for images, so image is available in build

* Bump node-fetch from 2.6.6 to 2.6.7 (#962)

Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.6 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](node-fetch/node-fetch@v2.6.6...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add search icon to search bar (#955)

* Add search icon to search bar

* Reverse if logic

* Resolve PR threads -> SearchIcon

* Use SVG as inline component and not background-image

* Upgrade msw to 0.36.7 (#965)

* Update version to 1.1.0

* Add map legend hbi (#960)

* Add first static MapLegend for accidents & cadastre

* Add individual legend components

* Map Legend toggle working with button

* Add Link & Hint to Legend

* Add correct Incidient legend items with POints

* Fix styling for bottom link/text in MapLegend

* Fixed different Header style in Flexbox

* Fix linter issues

* Use React hooks as imported functions

The pattern I suggest is, to import React hook `React.use*` directly. But use `React.FC` and such when using React-Types.

* Create Component ModalCloseIcon

Move the local component to be a full component in our components2 folder.
Use it for the Kataster legend.

This fixes an issue, that the border lines of the close-icon are cut off.

* Fix fill color for Kataster legend

The gray of the outline was lighter than the gray of the location icon below due to this svg filter stuff.

* Horizontal navigation bar (#953)

* Rename MapLegend to MapSelectorBar & rudimentary Selector Bar functionality

Reduce misunderstandings

* Fix margin in MapSelectorBar in default mode

* Docs comments lint small fixes (#951)

* Readme: Add link to todenv

* Gastro: Re-activate the gastro app on staging for testing

* Map: Add comment about release-system

* Remove false empty space in URL

* CSS: Fix Links styles

- white space none was overwritten to pre-wrap below.
- padding none is invalid, should be 0.

* Comment breakpoints

* Document Dotenv

* Update mui-utils.ts

```
createTheme.js?2bfd:94 Material-UI: the createMuiTheme function was renamed to createTheme.

You should use `import { createTheme } from '@material-ui/core/styles'
`
``

* Remove popupbikelanes map and route (#952)

* Remove and redirect /popupbikelanes Map

Those are part of the regular planning view, now.

* Remove /popupbikelanes Routes

* Add `.editorconfig` and `.vscode` files (#947)

* Add `.editorconfig` and `.vscode` files

Start streamlining editor settings.

* Add styled component recommended extension

* .vscode/settings: Remove organizeImports

This does not work great. It deletes imports too early, eg when there is an error in your code formatting or a snipped is commented out for testing. We have to do this manually per file, for now.

Co-authored-by: Henri <henri@fixmycity.de>

* eslint config: Remove import order rules (#950)

I suggest we remove this rule and instead rely on VS Codes "Organize Imports" which can be done on save https://eshlox.net/2019/12/02/vscode-automatically-organize-typescript-imports/

* Xhain: Fix last name & update official status (#949)

"HerRmann"

She is no longer the mayor of Friedrichshain-Kreuzberg and uses "Ex-" in front of her former job title for herself now (Eg. Twitter).

* Improve mouse hover map (#936)

* Integrate improvements for map events for hovering by @tordans

* Add pointer cursor for marker images

* Refactor registerMouseHoverHandler

Co-authored-by: Tobias <tobias@fixmycity.de>

* HBI: Add WelcomeModal, update HBI-FAQ (#946)

* Use Link component for FAQ

Which styles them is the right way.

* Update FAQ with content about current HBI

* WebglMap: Extract map/indexView into Component state

* Introduce WelcomModal on WebglMap

Use URL schema `/zustand?lat=50.1&lng=10&zoom=10` to set the map, which is a hidden feature.

* Extract ModalCloseIcon into Component

* WelcomeModal: Fix `aria-*` attributes

- Document aria-controls
- Fix cut off border in SVG with overflow styles; also css width is better than attribute width
- Add Modal-aria-attributes

* Remove 'beta' from Logo

* Improve MapSelectorBar & SVG file using new alignment system

Now the MapSelectorBar is perfectly horizontal on Desktop and vertical on mobile

* Fix MapSelectorBar for embed mode

* Fix prettier warnings.

* Disable MapLegend for now

* Improve SVG sizes for braces

* Resolve obsolete display: block

* Remove test for MapLegend

* Fix problems mentioned in PR

* HBI: Refactor WelcomeModal, Fix Links in Modal, Fix Overlay-Layer visibility (#954)

* WelcomeModal: Extract styles in separate file

* WelcomeModal: Split Components, Fix Column2 Center/Zoom

- Center/Zoom for Column2 does not reload the page anymore, so the closed-State of the modal is preserved.
- Column1 still has a reload, though. But this is less annoying.
- Columns are split into Components to keep the Modal Component small.

* Map: Bugfix: Overlay layers where not filtered properly

Fixes #934

* Add individual legend components

* Map Legend toggle working with button

* Add Link & Hint to Legend

* Add correct Incidient legend items with POints

* Fix styling for bottom link/text in MapLegend

* Fixed different Header style in Flexbox

* Fix linter issues

* Upgrade to styled-components v5 (#961)

* Use React hooks as imported functions

The pattern I suggest is, to import React hook `React.use*` directly. But use `React.FC` and such when using React-Types.

* Create Component ModalCloseIcon

Move the local component to be a full component in our components2 folder.
Use it for the Kataster legend.

This fixes an issue, that the border lines of the close-icon are cut off.

* Fix fill color for Kataster legend

The gray of the outline was lighter than the gray of the location icon below due to this svg filter stuff.

* Set fixed width for MapSwitchWrapper

* Readd MapLegend to correspond to target branch

* Rename MapLegend to MapSelectorBar & rudimentary Selector Bar functionality

Reduce misunderstandings

* Fix margin in MapSelectorBar in default mode

* Improve MapSelectorBar & SVG file using new alignment system

Now the MapSelectorBar is perfectly horizontal on Desktop and vertical on mobile

* Fix MapSelectorBar for embed mode

* Fix prettier warnings.

* Improve SVG sizes for braces

* Resolve obsolete display: block

* Fix problems mentioned in PR

* Set fixed width for MapSwitchWrapper

Co-authored-by: Tobias <tobias@fixmycity.de>
Co-authored-by: Niklas S <75360839+njklas@users.noreply.github.com>

* Improve imports & exports through barrel file

* Improve handling of props and their types

* Map Legend button toggles Legend now

* Moved MapLegend component to legacy components/ folder

Moved images & icons into assets folder

* Fix maplegend color

* Improved spacings of headlines

* Remove StyledCloseIcon & fix z-index failure for WelcomeModal

* Fix more z-index issues & fix mobile view width

Close Icon was not visible on small device

* Fix position of points in legend

* Improve lengths for Legend

Co-authored-by: Tobias <tobias@fixmycity.de>
Co-authored-by: Niklas S <75360839+njklas@users.noreply.github.com>

* Fix Legend height on mobile

* Remove storybook dependencies

* Disable storybook -> temporarily disable Lint issues

* Implement fixes and improvements for HBI 2.0

Squashed commit of the following:

commit acad9b845194a9c66967138b2e0624dc45d2948e
Merge: beaa887c f7d9577
Author: Henri <henri@fixmycity.de>
Date:   Thu Feb 10 11:49:12 2022 +0100

    Merge branch 'develop' into improve-hbi-refresh

commit beaa887c1ad4dd1a505e1d874e5e19f8efb53478
Author: Henri <henri@fixmycity.de>
Date:   Thu Feb 10 11:48:34 2022 +0100

    Update npm packages (lock file)

commit f739cfb
Author: Henri <henri@fixmycity.de>
Date:   Thu Feb 10 11:43:09 2022 +0100

    Fix test config in package.json again

commit 58b3dcb
Author: Henri <henri@fixmycity.de>
Date:   Thu Feb 10 11:38:17 2022 +0100

    Fix tests for HBI interpolation zoom

commit f66b6dc
Author: Henri <henri@fixmycity.de>
Date:   Wed Feb 9 11:19:14 2022 +0100

    Improve Mail in WelcomeModal using AnchorLink component

commit f1c8603
Author: Henri <henri@fixmycity.de>
Date:   Wed Feb 9 11:18:50 2022 +0100

    Fix Close Icon & on focus

    xlink:href is deprecated: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href

commit 533e613
Author: Henri <henri@fixmycity.de>
Date:   Wed Feb 9 10:53:37 2022 +0100

    Optimize maplegend icon activated in size

commit 578a4e0
Author: Henri <henri@fixmycity.de>
Date:   Wed Feb 9 10:40:13 2022 +0100

    Fix planning filters for changing visibility of tracks

commit dba8bb7
Author: Henri <henri@fixmycity.de>
Date:   Tue Feb 8 11:49:04 2022 +0100

    Fix visibility of layers on high zoom / adapt to Mapbox Studio style

commit f352018
Author: Henri <henri@fixmycity.de>
Date:   Mon Feb 7 09:51:47 2022 +0100

    Add active state of map legend icon

commit 15671c7
Author: Henri <henri@fixmycity.de>
Date:   Mon Feb 7 09:44:43 2022 +0100

    Hide Legend Close Icon on Desktop

commit a5b03f0
Author: Henri <henri@fixmycity.de>
Date:   Mon Feb 7 09:33:22 2022 +0100

    Bump up required npm version because of changed lock file version in npm@8

commit e77533b
Author: Henri <henri@fixmycity.de>
Date:   Mon Feb 7 09:31:41 2022 +0100

    Fix text in WelcomModale

* Fix mapbox style url property key issue

The mapbox style urls have been passed through property called "style", which is defined by react for CSS styling. Therefore the string was incorrectly transformed into an object

Changing this to a more specific property key, this resolves the issue.

* Hotfix search icon map

* Fix padding for Button wrapper in WelcomeModal

* Add HBI intersection data to Press page (#973)

* Fix padding for Button wrapper in WelcomeModal

* Add HBI intersection data to Press page

* Add license & sources for hbi data

Co-authored-by: Vincent Ahrend <mail@vincentahrend.com>
Co-authored-by: Tobias <tobias@fixmycity.de>
Co-authored-by: Niklas S <75360839+njklas@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@vbraun
Copy link

vbraun commented Feb 23, 2022

I think there are multiple ways that you can end up triggering webpack's automatic publicPath detection, which then fails with the not-very-helpful error message from the issue title. Its definitely not just mini-css-extract-plugin.

Instead of trying to override the webpack configuration for all webpack core/plugins that have a publicPath setting, I have the following vile hack to trick webpack's automatic detection into not throwing an error. Put

/**
 * Workaround for the "Automatic publicPath is not supported in this browser" fail
 *
 * See https://github.com/cypress-io/cypress/issues/18435 for more
 * details. Should be removed when cypress switches to webpack 5.
 */
var scripts = document.getElementsByTagName("script");
scripts[scripts.length - 1].src = ' ';  // yes, thats a single space and not the empty string

into your cypress/support/index.ts (or wherever supportFile from cypress.json points to)

@Circle6
Copy link

Circle6 commented Mar 15, 2022

I've tried running through all the given solutions here and i'm still seeing this issue. I'm even explicitly setting the publicPath and it's still throwing "Automatic publicPath is not supported in this browser".

Any progress on fixing this?

@NiklasPor
Copy link

@Circle6 copying this over from another issue. Add the following code into your plugins/index.js file

  const publicPath = ' ';
  let outputOptions;
  Object.defineProperty(webpackOptions, 'output', {
    get: () => {
      return { ...outputOptions, publicPath };
    },
    set: function (x) {
      outputOptions = x;
    },
  });

My complete plugins/index.js config file looks like this (Angular + Nx):

import { dynamicImport } from 'tsimportlib';

// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
module.exports = async (on, config) => {
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config
  const linkerPlugin = await dynamicImport('@angular/compiler-cli/linker/babel', module);
  const webpackPreprocessor = require('@cypress/webpack-batteries-included-preprocessor');
  const webpackOptions = webpackPreprocessor.defaultOptions.webpackOptions;

  webpackOptions.module.rules.unshift({
    test: /\.mjs$/,
    loader: 'babel-loader',
    options: {
      compact: false,
      plugins: [linkerPlugin.default],
    },
    resolve: {
      fullySpecified: false,
    },
  });

  const publicPath = ' ';
  let outputOptions;
  Object.defineProperty(webpackOptions, 'output', {
    get: () => {
      return { ...outputOptions, publicPath };
    },
    set: function (x) {
      outputOptions = x;
    },
  });

  on(
    'file:preprocessor',
    webpackPreprocessor({
      webpackOptions: webpackOptions,
      typescript: require.resolve('typescript'),
    })
  );

  return config;
};

bkjohnson added a commit to department-of-veterans-affairs/component-library that referenced this issue May 11, 2022
bkjohnson added a commit to department-of-veterans-affairs/component-library that referenced this issue May 12, 2022
* Try publicPath: '' workaround

This workaround is mentioned in a few places:

- https://stackoverflow.com/a/64715069
- cypress-io/cypress#18435 (comment)

* Remove trailing quote in Spanish translation

* Bump all versions for prerelease testing

* Prepare versions for next stable release
@Janaka-Steph
Copy link

Janaka-Steph commented Jun 7, 2022

Is there a reason why setting publicPath: '' in https://github.com/cypress-io/cypress/blob/master/npm/webpack-preprocessor/index.ts#L204 has never been done, or is it simply because nobody bothered to make a PR ?
This is the only workaround that works for me.

@MiguelNiblock
Copy link

I was having this issue with dynamic imports, and fixed it by using require instead

previous:

const { default: Sentry } = await import('./Sentry')

solution:

  const Sentry = (await require('./Sentry')) as Sentry

@johncrim
Copy link

johncrim commented Jul 2, 2022

I'm still seeing the same issue (both cypress 9 and cypress 10). Adding output.publicPath='' (or =' ' - doesn't seem to matter) to webpack-preprocessor fixed the issue; I'll see if any of the other hacky but at least useable fixes work.

We're not using mini-css-extract-plugin, just ts-loader.

It's crazy to me that this hasn't been fixed previously (though it's arguably a webpack bug).

@johncrim
Copy link

johncrim commented Jul 2, 2022

The defineProperty(webpackConfig, 'output') hack worked for me. My implementation was different enough from the prior example that I'll include it here to help others.

Here's a generic plugins/index.ts that should work with an external webpack config file:

/* Cypress plugins/index.ts */
/// <reference types="cypress" />

import webpackPreprocessor from '@cypress/webpack-preprocessor';

import webpackConfig from '../cypress.webpack.config';

// Patch webpackConfig.output so it returns a `publicPath`, even though output is overwritten in webpackPreprocessor
// Credit: https://github.com/cypress-io/cypress/issues/8900#issuecomment-866897397
// https://github.com/cypress-io/cypress/issues/18435
const publicPath = '';
let outputOptions = {};
Object.defineProperty(webpackConfig, 'output', {
  get: () => {
    return { ...outputOptions, publicPath };
  },
  set: function (x) {
    outputOptions = x;
  }
});

/**
 * @type {Cypress.PluginConfig}
 */
module.exports = /*async if needed*/ (on: Cypress.PluginEvents, config: Cypress.ResolvedConfigOptions) => {

  on('file:preprocessor', webpackPreprocessor({
    webpackOptions: webpackConfig
  }));

  return config;
};

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: backlog labels Sep 9, 2022
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Sep 19, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 19, 2022

The code for this is done in cypress-io/cypress#23760, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 27, 2022

Released in 10.9.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v10.9.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Sep 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.