Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
035ac7d
Experiments in XP
espen42 Dec 7, 2018
0f11fbe
Refactoring a little.
espen42 Dec 7, 2018
73949f2
Package.lock
espen42 Dec 7, 2018
67dd3f9
Including the vscode project
espen42 Dec 14, 2018
087f20d
npm lock
espen42 Dec 14, 2018
dfd5d05
Webpack compileses JSX
espen42 Dec 14, 2018
2a746fd
Started setting up server-side react rendering. See:
espen42 Dec 14, 2018
d4a7b67
Webpack builds and compiles.
espen42 Dec 25, 2018
18d6017
Webpack: separate entries for each component file. Code splitting, ma…
espen42 Dec 25, 2018
88a3522
Webpack: WiP on collecting contenthashed assetNames into the HTML tem…
espen42 Dec 25, 2018
b85a977
Webpack done: module.exports.output.path defines the base for relativ…
espen42 Dec 26, 2018
2f60a71
Micro adjustments
espen42 Dec 26, 2018
f7ec7d6
Webpack: Much better build, auto-chunks subdirectories of the home fo…
espen42 Dec 26, 2018
b4e7b5d
Gradle: moves the built index.html into the right place
espen42 Dec 26, 2018
135781f
Build: removed the _common underscore, and made getEntries take an ex…
espen42 Dec 27, 2018
06af227
React problem fixed. Cleans output folder.
espen42 Dec 27, 2018
3fd4988
Webpack builds better, keeping the folder structure below _entries. A…
espen42 Jan 4, 2019
fd663d3
Plan and started some XP boilerplate (generic page and part). Expand …
espen42 Jan 4, 2019
3fddd55
Started implementing The Plan.
espen42 Jan 4, 2019
2f76779
Keep working on part-specific jsx.
espen42 Jan 6, 2019
ffba279
Renamed jsx4xp to j4x everywhere. Made build less /jsx/ specific, ope…
espen42 Jan 6, 2019
fa2933a
index.html problem: slight improvement after moving index.html down. …
espen42 Jan 6, 2019
b00bf9c
Builds site jsx files. No longer hashes entries under site or j4x. Ex…
espen42 Jan 6, 2019
c95f99a
Transpiles XP source files separately from the J4X webpack step. MILE…
espen42 Jan 6, 2019
c088dee
Renaming all the things to react4xp, r4xp or r4x. Trying to serve a c…
espen42 Jan 8, 2019
fb17e93
Fixed service: can fetch react4xp assets through _/service/com.enonic…
espen42 Jan 11, 2019
80a8b4e
Test part fetches transpiled component corrently. But it doesn't seem…
espen42 Jan 11, 2019
1fd62bf
WORKS!!! Albeit hacky. Loads dependencies too, runs the library and t…
espen42 Jan 11, 2019
0454747
Works. Got rid of .name and /assets/, and moved commonChunks to the r…
espen42 Jan 12, 2019
85058e4
Works. Got rid of the hacky and unsafe trigger in the controller. Nex…
espen42 Jan 12, 2019
48b1284
Works. Separated out React4xp lib, with telescope-ably configurable c…
espen42 Jan 13, 2019
3fe7991
Works. Wrapping the rendering and fetching of targetId and props, in …
espen42 Jan 13, 2019
d198517
WiP, can insert html (or xml) at end of root element.
espen42 Jan 16, 2019
823387a
Works. Complex part uses three components from different places, buil…
espen42 Jan 16, 2019
d63b768
Works better. Pre-existing target elements can now be targeted.
espen42 Jan 16, 2019
a273cd5
NOT working: first attempt at server-side rendering. Or rather, first…
espen42 Jan 16, 2019
5ec5c0f
Checking out nashorn polyfill, console.log and global variable
espen42 Jan 16, 2019
111497f
Maybe successfully polyfilled require?
espen42 Jan 16, 2019
7fef4b6
Works in frontend: updated building of fronted chunkAssetBundles from…
espen42 Jan 19, 2019
bed6564
SSR Wip: Couldn't get nashorn-commonjs-modules to work (include group…
espen42 Jan 19, 2019
5f670fc
State of WiP. Nothing works here. This is not the commit you're looki…
espen42 Jan 19, 2019
c14c806
Workin' on the build scripts
espen42 Jan 19, 2019
d6cddf8
Pretty nicely modularized gradle
espen42 Jan 19, 2019
d301d51
Works again. Neat building. Uses library properly to separate the ren…
espen42 Jan 19, 2019
63b705e
Works, with externals.
espen42 Jan 20, 2019
9478553
Works. Autogenerates the externals source file prior to transpiling i…
espen42 Jan 20, 2019
141e592
Comments and tidying. Ready to move on: are these transpiled assets r…
espen42 Jan 20, 2019
7970e5d
Little bit of docs
espen42 Jan 20, 2019
64b67b9
Fixed the component name reference that broke the complex-reactive pa…
espen42 Jan 20, 2019
78e4f23
Fetches transpiled dependency scripts (externals, core, and common co…
espen42 Jan 20, 2019
fc37ac5
Working on nashorn polyfills. Map and setTimeout no longer throw erro…
espen42 Jan 20, 2019
60e83b1
Improved naming and structure of chunk json files
espen42 Jan 20, 2019
bbee7e0
Nashorn polyfilling: transpiling nashorn polyfills to file instead of…
espen42 Jan 20, 2019
70aa88a
It worked! ReactDOMServer.renderToString worked! I am a demi-god! Now…
espen42 Jan 20, 2019
5bac267
SSR renderToStaticMarkup works. Returns rendered HTML to frontend. Wr…
espen42 Jan 20, 2019
72203f7
SSR Engine refactoring, single instance pattern. Todo: make component…
espen42 Jan 20, 2019
bca4943
Only initializing engine and components once, storing components as f…
espen42 Jan 20, 2019
fd3d90d
This will not build - only intended to tell what's next in developmen…
espen42 Jan 20, 2019
5703fad
Untested, but this constructor should be much better. Needs some fina…
espen42 Jan 21, 2019
98dd31b
Works. Bugfixed the improved constructor, demonstrated in the 3 parts.
espen42 Jan 21, 2019
444d07e
An optimization idea.
espen42 Jan 21, 2019
a7a6b32
Todo: More plans
espen42 Jan 21, 2019
0ee0bca
More comments and thoughts
espen42 Jan 21, 2019
c476d49
Untested: streamlined pageContributions and client rendering call, by…
espen42 Jan 23, 2019
f3a8239
Bugfix. Previous improvement works now. Added a nashornPolyfills webp…
espen42 Jan 23, 2019
5c6fa00
Halfway there for adding rendered content into container at SSR step
espen42 Jan 23, 2019
69c40c3
Better structure in lib.react4xp.index.es6. Lacks the java functional…
espen42 Jan 23, 2019
f6be344
SSRendered HTML is inserted at target element inside pre-existing body.
espen42 Jan 24, 2019
60df9e7
Java cleanup.
espen42 Jan 24, 2019
a128d36
Works badly. A counter component. Can insert data into props from XP …
espen42 Jan 24, 2019
49e3023
SSR: Returns error message if script fails
espen42 Jan 25, 2019
4aae88b
Works! Neat! Recommended rendering for basic use: See counter.es6
espen42 Jan 25, 2019
29a1f46
Slight cleanup
espen42 Jan 25, 2019
089e156
Label instead of default value
espen42 Jan 25, 2019
427bd00
Cleanup: removed most of the examples, left behind a minimal hello-wo…
espen42 Jan 26, 2019
e2a39e7
Works. Auto-handles all contenthashed chunk names and separation betw…
espen42 Jan 26, 2019
ce353a6
Removed obsolete test components, leaving behind example part
espen42 Jan 26, 2019
b206df7
Gitignore vscode project files
espen42 Jan 26, 2019
a2e269d
More cleanup: gitignore, gradle and npm
espen42 Jan 26, 2019
3dd1b68
Cleanup scratchpad
espen42 Jan 26, 2019
7323850
Cleanup: big comment
espen42 Jan 26, 2019
aee34f1
webpack.config.react4xp.js: wrapped getEntries routine in a function,…
espen42 Jan 26, 2019
68c00a8
Making the entry list file prettier, since it can be used to look up …
espen42 Jan 26, 2019
f17996c
Started working in the README.md
espen42 Jan 26, 2019
44ce968
Better method documentation in the react4xp lib.
espen42 Jan 27, 2019
db46f48
First-draft documentation done.
espen42 Jan 27, 2019
81868c5
Example format
espen42 Jan 27, 2019
c8aeb07
Update README.md. So much readme.
espen42 Jan 27, 2019
85aa36e
Added SSR+hydration rendering. Will this be enough, or is the window.…
espen42 Feb 1, 2019
cae5983
SSR Hydration works. Stretch tested with a react-redux example and th…
espen42 Feb 2, 2019
13a0ef6
Hydration, works. Improved asset-service HTTP caching strategy.
espen42 Feb 3, 2019
2cf279c
Asset-serving strategy: body-end instead of head-end assets. That way…
espen42 Feb 3, 2019
6ec5120
A bit of comment and readme about the hydrating rendering.
espen42 Feb 3, 2019
76c531d
Removed examples
espen42 Feb 3, 2019
a733cd3
Re-inserted the simplest example and corrected mistake in readme.
espen42 Feb 3, 2019
42199fc
Update README.md
espen42 Feb 3, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,15 @@ crashlytics-build.properties

# Node modules
node_modules/
bin/

# Visual studio code project files
bin/
.vscode/
_vscode/
.project
.classpath
.settings/



**/_AUTOGENERATED_externals_.es6
170 changes: 169 additions & 1 deletion README.md

Large diffs are not rendered by default.

Empty file removed bin/admin/tools/.gitkeep
Empty file.
Empty file removed bin/admin/widgets/.gitkeep
Empty file.
10 changes: 0 additions & 10 deletions bin/app/App.jsx

This file was deleted.

7 changes: 0 additions & 7 deletions bin/app/index.js

This file was deleted.

12 changes: 0 additions & 12 deletions bin/application.svg

This file was deleted.

3 changes: 0 additions & 3 deletions bin/application.xml

This file was deleted.

Empty file removed bin/assets/.gitkeep
Empty file.
11 changes: 0 additions & 11 deletions bin/index.html

This file was deleted.

Empty file removed bin/lib/.gitkeep
Empty file.
37 changes: 0 additions & 37 deletions bin/main.js

This file was deleted.

Empty file removed bin/services/.gitkeep
Empty file.
Empty file removed bin/site/content-types/.gitkeep
Empty file.
Empty file removed bin/site/error/.gitkeep
Empty file.
Empty file removed bin/site/filters/.gitkeep
Empty file.
Empty file removed bin/site/i18n/.gitkeep
Empty file.
Empty file removed bin/site/layouts/.gitkeep
Empty file.
Empty file removed bin/site/mixins/.gitkeep
Empty file.
Empty file removed bin/site/pages/.gitkeep
Empty file.
Empty file removed bin/site/parts/.gitkeep
Empty file.
4 changes: 0 additions & 4 deletions bin/site/site.xml

This file was deleted.

Empty file removed bin/views/.gitkeep
Empty file.
145 changes: 140 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ node {


dependencies {

include "com.enonic.xp:lib-repo:${xpVersion}"
include "com.enonic.xp:lib-node:${xpVersion}"
compile "com.enonic.xp:core-api:${xpVersion}"
Expand All @@ -27,23 +26,159 @@ dependencies {
include "com.enonic.xp:lib-portal:${xpVersion}"
include "com.enonic.xp:lib-io:${xpVersion}"
include "com.enonic.xp:lib-mustache:${xpVersion}"
include "com.enonic.xp:lib-thymeleaf:${xpVersion}"

include "com.enonic.lib:lib-router:1.0.1"
include 'com.enonic.lib:util:1.3.0'
include 'com.enonic.lib:lib-cache:1.1.0'

include group: 'org.jdom', name: 'jdom', version: '2.0.2'
include group: 'org.json', name: 'json', version: '20180813'
include group: 'jaxen', name: 'jaxen', version: '1.1.6'
}

repositories {
mavenLocal()
jcenter()
xp.enonicRepo()
maven {
url 'http://repo.enonic.com/public'
}
}



task webpack(type: NodeTask) {
npmInstall.inputs.file("package.json")
npmInstall.inputs.file("package-lock.json")
npmInstall.outputs.dir("node_modules")


// Transpile .js and .es6 files under src/main/resources.
// These are "pure XP" source code files, not JS (and react) assets. Those must be transpiled separately, by the webpackReact4xp task below.
// This is currently done by reserving .es6 and .js files below src/main/resources/ for this task,
// while reserving .JSX files under that, and all relevant extensions in other locations, for the webpackReact4xp task.
task babelXP(type: NodeTask) {
script = file('node_modules/babel-cli/bin/babel.js')
args = ["src/main/resources", "--out-dir", "build/resources/main", "--ignore", "**/*.jsx"]

inputs.dir 'src/main/resources'
outputs.dir "build/resources/main"
}
babelXP.dependsOn += 'npmInstall'
babelXP.dependsOn += 'processResources'

import groovy.json.JsonSlurper

task webpack_r4xp_externals(type: NodeTask) {
doFirst {
/* Generate an entry file for bundling externals into one cacheable file.
For example (if the file webpack.config.constants.json contains an EXTERNALS object like this: { "react": "React", "react-dom": "ReactDOM" } ):

import ReactDOM from 'react-dom';
import React from 'react';

(function(window){
window.React = React;
window.ReactDOM = ReactDOM;
})(typeof window !== 'undefined' ? window : global);
*/

String externalsJson = new File('webpack.config.constants.json').text;
def jsonSlurper = new JsonSlurper()
def exts = jsonSlurper.parseText(externalsJson).EXTERNALS

def externalsImports = "";
def externalsExports = "";
exts.each{ k, v -> externalsImports += "import ${v} from '${k}';\n" }
//exts.each{ k, v -> externalsImports += "console.log('${v}: ' + ${v});\n" }
exts.each{ k, v -> externalsExports += "\twindow.${v} = ${v};\n" }

def externalsES6 = "// AUTO-GENERATED in gradle task 'webpack_r4xp_externals'\n\n" +
externalsImports +
"\n(function(window) {\n" +
externalsExports +
"} )(typeof window !== 'undefined' ? window : global);\n"

def externalsFile = new File('src/main/react4xp/_AUTOGENERATED_externals_.es6')
externalsFile.write externalsES6

}

script = file('node_modules/webpack/bin/webpack.js')
args = ['--config', 'webpack.config.react4xp.externals.js', '--progress', '--color']

inputs.file("webpack.config.react4xp.externals.js")

inputs.file("webpack.config.constants.json")
inputs.file("webpack.config.constants.js")
inputs.file("package.json")
inputs.file("package-lock.json")
inputs.dir("src/main/react4xp")
outputs.dir("build/resources/main/react4xp")
}
webpack_r4xp_externals.dependsOn += 'npmInstall'


task webpack_r4xp_nashornPolyfills(type: NodeTask) {
script = file('node_modules/webpack/bin/webpack.js')
args = ['--config', 'webpack.config.react4xp.nashornPolyfills.js', '--progress', '--color']

inputs.file("webpack.config.react4xp.nashornPolyfills.js")

inputs.file("webpack.config.constants.json")
inputs.file("webpack.config.constants.js")
inputs.file("package.json")
inputs.file("package-lock.json")
inputs.dir("src/main/react4xp")
outputs.dir("build/resources/main/react4xp")
}
webpack_r4xp_nashornPolyfills.dependsOn += 'npmInstall'


task webpack_r4xp_frontCore(type: NodeTask) {
script = file('node_modules/webpack/bin/webpack.js')
args = ['--config', 'webpack.config.react4xp.core.js', '--progress', '--color']

inputs.file("webpack.config.react4xp.core.js")

inputs.file("webpack.config.constants.json")
inputs.file("webpack.config.constants.js")
inputs.file("package.json")
inputs.file("package-lock.json")
inputs.dir("src/main/react4xp")
outputs.dir("build/resources/main/react4xp")
}
webpack_r4xp_frontCore.dependsOn += 'npmInstall'


task webpack_r4xp(type: NodeTask) {
script = file('node_modules/webpack/bin/webpack.js')
args = ['--config', 'webpack.config.react4xp.js', '--progress', '--color']

inputs.file("webpack.config.react4xp.js")
inputs.dir("src/main/resources/site")

inputs.file("webpack.config.constants.json")
inputs.file("webpack.config.constants.js")
inputs.file("package.json")
inputs.file("package-lock.json")
inputs.dir("src/main/react4xp")
outputs.dir("build/resources/main/react4xp")

/*doLast {
file("build/resources/main/assets/index.html").renameTo(file("build/resources/main/index.html"))
}*/
}
webpack_r4xp.dependsOn += 'npmInstall'



// processes your package.json before running webpack
webpack.dependsOn 'npmInstall'
webpack.dependsOn 'processResources'
jar.dependsOn babelXP
jar.dependsOn += 'webpack_r4xp'
jar.dependsOn += 'webpack_r4xp_frontCore'
jar.dependsOn += 'webpack_r4xp_externals'
jar.dependsOn += 'webpack_r4xp_nashornPolyfills'

jar.outputs.dir('build/libs')

jar.dependsOn webpack
Loading