Skip to content

Commit

Permalink
BACKLOG-23366: Migrate to @jahia/javascript-modules-library (#26)
Browse files Browse the repository at this point in the history
Migrate from using @jahia/js-server-core to using @jahia/javascript-modules-library NPM package dependency
  • Loading branch information
baptistegrimaud authored Nov 29, 2024
1 parent 26abcb7 commit 8c815ce
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
},
"dependencies": {
"@jahia/js-server-core": "^0.0.17",
"@jahia/javascript-modules-library": "^0.0.4",
"graphql": "^16.7.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as jahiaTemplates from './templates';
import * as jahiaViews from './views';
import {registerJahiaComponents} from '@jahia/js-server-core';
import {registerJahiaComponents} from '@jahia/javascript-modules-library';

registerJahiaComponents(jahiaTemplates);
registerJahiaComponents(jahiaViews);
2 changes: 1 addition & 1 deletion src/server/templates/page/PageHome.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {AddResources, Area, defineJahiaComponent, useUrlBuilder} from '@jahia/js-server-core';
import {AddResources, Area, defineJahiaComponent, useUrlBuilder} from '@jahia/javascript-modules-library';

export const PageHome = () => {
const {buildStaticUrl} = useUrlBuilder();
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/ctaSection/CtaSectionDefault.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {useServerContext, getNodeProps, buildUrl, defineJahiaComponent } from '@jahia/js-server-core';
import {useServerContext, getNodeProps, buildUrl, defineJahiaComponent } from '@jahia/javascript-modules-library';

export const CtaSectionDefault = () => {
const {currentNode, renderContext, currentResource} = useServerContext();
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/feature/FeatureDefault.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {useServerContext, getNodeProps, buildUrl, defineJahiaComponent} from '@jahia/js-server-core';
import {useServerContext, getNodeProps, buildUrl, defineJahiaComponent} from '@jahia/javascript-modules-library';

export const FeatureDefault = () => {
const {currentNode, renderContext, currentResource} = useServerContext();
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/featureSection/FeatureSectionDefault.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {Render, AddContentButtons, useServerContext, getChildNodes, defineJahiaComponent} from '@jahia/js-server-core';
import {Render, AddContentButtons, useServerContext, getChildNodes, defineJahiaComponent} from '@jahia/javascript-modules-library';

export const FeatureSectionDefault = () => {
const { currentNode } = useServerContext();
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/hello/HelloDefault.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import {useServerContext, getNodeProps, defineJahiaComponent} from '@jahia/js-server-core'
import {useServerContext, getNodeProps, defineJahiaComponent} from '@jahia/javascript-modules-library'

export const HelloDefault = () => {
const { currentNode } = useServerContext();
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/heroSection/HeroSectionDefault.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {useServerContext, buildUrl, getNodeProps, defineJahiaComponent} from '@jahia/js-server-core';
import {useServerContext, buildUrl, getNodeProps, defineJahiaComponent} from '@jahia/javascript-modules-library';

export const HeroSectionDefault = () => {
const {currentNode, renderContext, currentResource} = useServerContext();
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/pricingSection/PricingSectionDefault.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getChildNodes,
getNodeProps,
defineJahiaComponent
} from '@jahia/js-server-core';
} from '@jahia/javascript-modules-library';

export const PricingSectionDefault = () => {
const {currentNode} = useServerContext();
Expand Down
2 changes: 1 addition & 1 deletion src/server/views/pricingTier/PricingTierDefault.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {useServerContext, getNodeProps, buildUrl, defineJahiaComponent} from '@jahia/js-server-core';
import {useServerContext, getNodeProps, buildUrl, defineJahiaComponent} from '@jahia/javascript-modules-library';

export const PricingTierDefault = () => {
const {currentNode, renderContext, currentResource} = useServerContext();
Expand Down
12 changes: 6 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = (env, argv) => {
let optimization = isDevelopment ? {} : {
minimizer: [
// This is required to make hydration working, as its implementation relies on the class name of the React component.
// See InBrowser.jsx in js-server-core for details
// See InBrowser.jsx in javascript-modules-library for details
new TerserPlugin({
terserOptions: {
keep_classnames: true,
Expand Down Expand Up @@ -118,11 +118,11 @@ module.exports = (env, argv) => {
},
externals: {
// Those libraries are supplied to webpack at runtime (by the npm-module-engine project), and are not packaged in the output bundle
'@jahia/js-server-core': 'jsServerCoreLibraryBuilder.getLibrary()',
react: 'jsServerCoreLibraryBuilder.getSharedLibrary(\'react\')',
'react-i18next': 'jsServerCoreLibraryBuilder.getSharedLibrary(\'react-i18next\')',
i18next: 'jsServerCoreLibraryBuilder.getSharedLibrary(\'i18next\')',
'styled-jsx/style': 'jsServerCoreLibraryBuilder.getSharedLibrary(\'styled-jsx\')'
'@jahia/javascript-modules-library': 'javascriptModulesLibraryBuilder.getLibrary()',
react: 'javascriptModulesLibraryBuilder.getSharedLibrary(\'react\')',
'react-i18next': 'javascriptModulesLibraryBuilder.getSharedLibrary(\'react-i18next\')',
i18next: 'javascriptModulesLibraryBuilder.getSharedLibrary(\'i18next\')',
'styled-jsx/style': 'javascriptModulesLibraryBuilder.getSharedLibrary(\'styled-jsx\')'
},
resolve: {
mainFields: ['module', 'main'],
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1613,17 +1613,17 @@ __metadata:
languageName: node
linkType: hard

"@jahia/js-server-core@npm:^0.0.17":
version: 0.0.17
resolution: "@jahia/js-server-core@npm:0.0.17"
"@jahia/javascript-modules-library@npm:^0.0.4":
version: 0.0.4
resolution: "@jahia/javascript-modules-library@npm:0.0.4"
dependencies:
graphql: "npm:^16.0.1"
graphql-tag: "npm:^2.12.6"
i18next: "npm:^23.10.1"
prop-types: "npm:^15.8.1"
react: "npm:^18.2.0"
react-i18next: "npm:^14.1.0"
checksum: 10c0/150625f6fffe1128ebcc3bdd15b6ff56883fa6eb992b85aa04fddf5d444a2330858cefab02e32a98e5a97e4947b353364545b90c0fb105b5b6289c5d531d813b
checksum: 10c0/0f84ecf855790f0ad477381664a7f99fc8ef45498718b750e3d90316abcc9f8e6b8f0dcda7d8349b9e40dc028a2c27c9763c99e3bbcd61e184a10cbf5b39a342
languageName: node
linkType: hard

Expand Down Expand Up @@ -7304,7 +7304,7 @@ __metadata:
"@babel/preset-env": "npm:^7.16.4"
"@babel/preset-react": "npm:^7.16.0"
"@jahia/eslint-config": "npm:^2.1.2"
"@jahia/js-server-core": "npm:^0.0.17"
"@jahia/javascript-modules-library": "npm:^0.0.4"
"@jahia/scripts": "npm:^1.3.6"
babel-loader: "npm:^8.2.3"
babel-plugin-transform-react-remove-prop-types: "npm:^0.4.24"
Expand Down

0 comments on commit 8c815ce

Please sign in to comment.