Skip to content

Commit

Permalink
Rename constants/Language module to the right suffix, and other act…
Browse files Browse the repository at this point in the history
…ions to make ESM bundlers happy. (#6130)

Co-authored-by: Steve Piercy <web@stevepiercy.com>
  • Loading branch information
sneridagh and stevepiercy authored Jun 28, 2024
1 parent 5144d2d commit 502c0f7
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 6 deletions.
17 changes: 17 additions & 0 deletions docs/source/upgrade-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,23 @@ The input field's placeholder text was moved above the buttons.
Together these changes improve usability both on small screens and in small containers, such as when the widget is in grid block elements.


### Renamed the `constants/Languages` module

`src/constants/Languages.js` has been renamed to `src/constants/Languages.cjs` since, in fact, it's a CommonJS module.
This change is needed for consistency with module suffixes in Volto core, in preparation for replacing Razzle with a modern builder.

The only Volto component that makes use of it is `PersonalPreferences`.
If you shadow it, then you should update this component.
For the rest, it is unlikely that your code refers to this module, since it's used internally by Volto itself.

### Renamed `test-setup-config` module

`test-setup-config.js` has been renamed to `test-setup-config.jsx` since, in fact, it contains JSX.
This change is needed for consistency with module suffixes in Volto core, in preparation for replacing Razzle with a modern builder.

It is unlikely that your code uses it, unless you heavily customized the Jest testing pipeline.


(volto-upgrade-guide-17.x.x)=

## Upgrading to Volto 17.x.x
Expand Down
1 change: 1 addition & 0 deletions packages/volto-slate/news/6130.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add proper dependencies to `volto-slate`. @sneridagh
8 changes: 7 additions & 1 deletion packages/volto-slate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@
"access": "public"
},
"dependencies": {
"classnames": "2.2.6",
"github-slugger": "1.4.0",
"image-extensions": "1.1.0",
"is-hotkey": "0.2.0",
"is-url": "1.2.4",
"jsdom": "^16.6.0",
"lodash": "4.17.21",
"react": "18.2.0",
"react-intersection-observer": "9.1.0",
"react-dom": "18.2.0",
"react-intersection-observer": "9.1.0",
"redux-mock-store": "1.5.4",
"slate": "0.100.0",
"slate-history": "0.100.0",
"slate-hyperscript": "0.100.0",
"slate-react": "0.98.4",
"uuid": "^9.0.1",
"weak-key": "^1.0.2"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/volto/news/6130.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Renamed `constants/Languages.js` to `constants/Languages.cjs` @sneridagh
2 changes: 1 addition & 1 deletion packages/volto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
},
"setupFiles": [
"./test-setup-globals.js",
"./test-setup-config.js"
"./test-setup-config.jsx"
],
"globalSetup": "./global-test-setup.js",
"setupFilesAfterEnv": [
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/razzle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const AfterBuildPlugin = require('@fiverr/afterbuild-webpack-plugin');
const fileLoaderFinder = makeLoaderFinder('file-loader');

const projectRootPath = path.resolve('.');
const languages = require('./src/constants/Languages');
const languages = require('./src/constants/Languages.cjs');

const packageJson = require(path.join(projectRootPath, 'package.json'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { toast } from 'react-toastify';

import { Toast } from '@plone/volto/components';
import { Form } from '@plone/volto/components/manage/Form';
import languages from '@plone/volto/constants/Languages';
import languages from '@plone/volto/constants/Languages.cjs';
import { changeLanguage } from '@plone/volto/actions';
import { toGettextLang } from '@plone/volto/helpers';
import config from '@plone/volto/registry';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ module.exports = {
pt_BR: 'Português (Brasil)',
zh_CN: '中文',
};

// export default languages;
2 changes: 1 addition & 1 deletion packages/volto/src/helpers/AuthToken/AuthToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function persistAuthToken(store, req) {
handleChange(true);
}

if (module.hot) {
if (module?.hot) {
module.hot.dispose((data) => {
data.reloaded = true;
});
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/src/server.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import userSession from '@plone/volto/reducers/userSession/userSession';

import ErrorPage from '@plone/volto/error';

import languages from '@plone/volto/constants/Languages';
import languages from '@plone/volto/constants/Languages.cjs';

import configureStore from '@plone/volto/store';
import { ReduxAsyncConnect, loadOnServer } from './helpers/AsyncConnect';
Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions styles/Vocab/Plone/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
`plone.volto`
[Aa]sync
[Bb]ackend
CommonJS
JavaScript
npm
nvm
Expand Down

0 comments on commit 502c0f7

Please sign in to comment.