Skip to content

Commit

Permalink
Merge pull request #12 from jwanner83/#4-refactoring
Browse files Browse the repository at this point in the history
#4 refactoring
  • Loading branch information
jwanner83 authored Sep 13, 2021
2 parents 8deedd1 + 88b09ee commit 0d1e314
Show file tree
Hide file tree
Showing 29 changed files with 752 additions and 320 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bin
node_modules
package-lock.json
.pnpm-debug.log
pnpm-lock.yaml
package-lock.json
yarn.lock
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
examples
src
src/classes
src/handlers
.idea
package-lock.json
3 changes: 3 additions & 0 deletions examples/plain/.npmbuildrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liferayDir": "/opt/liferay/"
}
3 changes: 1 addition & 2 deletions examples/plain/.npmbundlerrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"output-dir": "dist",
"features": {
"js-extender": true,
"web-context": "/plain",
"localization": "features/localization/Language"
"web-context": "/plain"
}
}
}
1 change: 0 additions & 1 deletion examples/plain/features/localization/Language.properties

This file was deleted.

4 changes: 2 additions & 2 deletions examples/plain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"javax.portlet.security-role-ref": "power-user,user",
"javax.portlet.display-name": "Plain"
},
"main": "index.js",
"main": "index",
"devDependencies": {
"copy-webpack-plugin": "4.6.0",
"liferay-npm-bundler-improved": "^1.0.0-beta.6",
"liferay-npm-bundler-improved": "^1.0.0-beta.7",
"liferay-npm-build-support": "^2.25.0",
"liferay-npm-bundler": "^2.25.0",
"webpack": "4.29.6",
Expand Down
17 changes: 8 additions & 9 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"description": "React",
"version": "1.0.0",
"scripts": {
"build": "liferay-npm-bundler-improved",
"deploy": "liferay-npm-bundler-improved -d /opt/liferayPlaygroundDXP73/deploy"
"dev:build": "liferay-npm-bundler-improved",
"dev:deploy": "liferay-npm-bundler-improved -d /opt/liferay/deploy"
},
"portlet": {
"com.liferay.portlet.display-category": "category.sample",
Expand All @@ -13,22 +13,21 @@
"javax.portlet.name": "react",
"javax.portlet.display-name": "React"
},
"main": "index.js",
"main": "index",
"dependencies": {
"react": "17.0.2",
"react-dom": "17.0.2",
"tslib": "^2.2.0"
"tslib": "^2.3.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^2.4.2",
"@rollup/plugin-typescript": "^8.2.1",
"@types/react": "^17.0.11",
"@types/react-dom": "^17.0.7",
"liferay-npm-bundler-improved": "^1.0.0-beta.6",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-terser": "^7.0.2",
"typescript": "^4.3.2"
"esbuild": "^0.12.27",
"liferay-npm-bundler-improved": "^1.0.0-beta.7",
"rollup-plugin-esbuild": "^4.5.0",
"typescript": "^4.4.2"
}
}
23 changes: 5 additions & 18 deletions examples/react/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
import commonjs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import typescript from '@rollup/plugin-typescript'
import { terser } from 'rollup-plugin-terser'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import esbuild from 'rollup-plugin-esbuild'

export default {
input: 'src/index.tsx',
output: [
{
file: 'dist/index.js',
format: 'commonjs'
format: 'commonjs',
exports: 'default'
},
],
plugins: [
peerDepsExternal(),
resolve(),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true
}),
commonjs({
sourceMap: false
}),
typescript({
sourceMap: false,
inlineSources: false
}),
terser()
commonjs(),
esbuild()
]
}
14 changes: 5 additions & 9 deletions examples/react/src/components/AppComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,36 @@ import LiferayParams from '../types/LiferayParams'
declare const Liferay: any

const AppComponent = (liferayParams: LiferayParams): any => {
const {
portletNamespace, contextPath, portletElementId, configuration,
} = liferayParams

return (
<div>
<div>
<span className="tag">
{Liferay.Language.get('portlet-namespace')} Deger
{Liferay.Language.get('portlet-namespace')}
:
</span>
<span className="value">{portletNamespace}</span>
<span className="value">{liferayParams.portletNamespace}</span>
</div>
<div>
<span className="tag">
{Liferay.Language.get('context-path')}
:
</span>
<span className="value">{contextPath}</span>
<span className="value">{liferayParams.contextPath}</span>
</div>
<div>
<span className="tag">
{Liferay.Language.get('portlet-element-id')}
:
</span>
<span className="value">{portletElementId}</span>
<span className="value">{liferayParams.portletElementId}</span>
</div>
<div>
<span className="tag">
{Liferay.Language.get('configuration')}
:
</span>
<span className="value pre">
{JSON.stringify(configuration, null, 2)}
{JSON.stringify(liferayParams.configuration, null, 2)}
</span>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion examples/react/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import ReactDOM from 'react-dom'
import 'tslib'
import AppComponent from './components/AppComponent'
import LiferayParams from './types/LiferayParams'

Expand Down
1 change: 0 additions & 1 deletion examples/react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"outDir": "build",
"sourceMap": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es5",
"typeRoots": [
"./node_modules/@types/"
],
Expand Down
11 changes: 4 additions & 7 deletions examples/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"description": "Vue",
"version": "1.0.0",
"scripts": {
"build": "liferay-npm-bundler-improved",
"deploy": "liferay-npm-bundler-improved -d /opt/liferayPlaygroundDXP73/deploy"
"dev:build": "liferay-npm-bundler-improved",
"dev:deploy": "liferay-npm-bundler-improved -d /opt/liferay/deploy"
},
"portlet": {
"com.liferay.portlet.display-category": "category.sample",
Expand All @@ -13,18 +13,15 @@
"javax.portlet.name": "vue",
"javax.portlet.display-name": "Vue"
},
"main": "index.js",
"main": "index",
"dependencies": {
"vue": "^2.6.14"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"liferay-npm-bundler-improved": "^1.0.0-beta.6",
"postcss": "^8.3.0",
"liferay-npm-bundler-improved": "^1.0.0-beta.7",
"rollup": "^2.51.1",
"rollup-plugin-preserve-shebangs": "^0.2.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-vue": "^4.7.2",
"vue-template-compiler": "^2.6.14"
}
Expand Down
6 changes: 0 additions & 6 deletions examples/vue/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import vuePlugin from 'rollup-plugin-vue'
import { terser } from 'rollup-plugin-terser'

export default {
input: 'src/index.js',
plugins: [
resolve(),
vuePlugin(),
commonjs(),
terser({
format: {
comments: false
}
})
],
output: [
{
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Vue from 'vue/dist/vue.common'
import Vue from 'vue'
import App from './components/index.vue'

export default function main ({ portletNamespace, contextPath, portletElementId, configuration }) {
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "liferay-npm-bundler-improved",
"description": "A highly experimental and non-official module which uses rollup to bundle javascript and provides it to liferay through a jar file.",
"version": "1.0.0-beta.6",
"version": "1.0.0-beta.7",
"author": "Jonas Wanner",
"license": "ISC",
"repository": {
Expand All @@ -18,26 +18,27 @@
"liferay-frontend",
"rollup"
],
"files": ["/bin"],
"bin": {
"liferay-npm-bundler-improved": "bin/bundler.js"
},
"dependencies": {
"jszip": "^3.6.0",
"ora": "^5.4.1",
"rollup": "^2.51.1"
"rollup": "^2.56.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-typescript": "^8.2.1",
"@types/yargs": "^17.0.2",
"chalk": "^4.1.1",
"rollup": "^2.51.1",
"rollup-plugin-preserve-shebangs": "^0.2.0",
"rollup-plugin-terser": "^7.0.2",
"yargs": "^17.0.1",
"tslib": "^2.3.0",
"typescript": "^4.3.2",
"tslib": "^2.3.0"
"yargs": "^17.0.2"
},
"scripts": {
"build": "rollup -c",
Expand Down
Loading

0 comments on commit 0d1e314

Please sign in to comment.