@jahia/create-module 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ nodeLinker: node-modules
2
+
3
+ yarnPath: .yarn/releases/yarn-4.3.1.cjs
@@ -9,3 +9,23 @@ If you don't use default configuration for the Docker container name or for Jahi
9
9
  ## Documentation
10
10
 
11
11
  You can find the documentation on how to use this module on the [Jahia Academy](https://academy.jahia.com/get-started/developers/templating) templating tutorial.
12
+
13
+ ## Run
14
+
15
+ 1) Enable Corepack if needed :
16
+
17
+ `enable corepack`
18
+
19
+ 2) Install the dependencies :
20
+
21
+ ``yarn``
22
+
23
+ 3) Build and run the project :
24
+
25
+ ``yarn watch``
26
+
27
+ ## How to upgrade yarn version to latest stable
28
+
29
+ This command will upgrade yarn to the latest stable release and update the yarn installer in .yarn/releases
30
+
31
+ ``yarn set version stable``
@@ -7,9 +7,12 @@
7
7
  dist
8
8
  node_modules
9
9
 
10
- # yarn v2
11
- .yarn/cache
12
- .yarn/unplugged
13
- .yarn/build-state.yml
14
- .yarn/install-state.gz
15
- .pnp.*
10
+ #Yarn
11
+ .yarn/*
12
+ !.yarn/cache
13
+ !.yarn/patches
14
+ !.yarn/plugins
15
+ !.yarn/releases
16
+ !.yarn/sdks
17
+ !.yarn/versions
18
+ yarn-error.log
@@ -3,18 +3,18 @@
3
3
  "version": "1.0.0",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
- "build": "webpack --mode=development",
6
+ "build": "webpack --mode=development --env pack",
7
+ "build:production": "webpack --mode=production --env pack",
7
8
  "deploy": "jahia-deploy",
8
- "watch": "yarn build --env deploy=true --watch",
9
+ "watch": "webpack --mode=development --env deploy --watch",
9
10
  "lint": "eslint .",
10
- "test": "yarn lint",
11
- "postinstall": "yarn dlx @yarnpkg/sdks vscode"
11
+ "test": "yarn lint"
12
12
  },
13
13
  "jahia": {
14
- "module-dependencies" : "default",
14
+ "module-dependencies": "default",
15
15
  "module-type": "templatesSet",
16
- "server": "dist/main.js",
17
- "static-resources" : "/css,/images,/javascript"
16
+ "server": "dist/main.js",
17
+ "static-resources": "/css,/images,/javascript"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@jahia/eslint-config": "^2.1.2",
@@ -31,11 +31,12 @@
31
31
  "webpack-shell-plugin-next": "^2.3.1"
32
32
  },
33
33
  "dependencies": {
34
- "handlebars": "^4.7.7",
35
- "@jahia/js-server-core" : "^0.0.4"
34
+ "@jahia/js-server-core": "^0.0.13",
35
+ "handlebars": "^4.7.7"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=16.0.0",
39
- "yarn": ">=3.0.0"
40
- }
39
+ "yarn": ">=4.0.0"
40
+ },
41
+ "packageManager": "yarn@4.3.1"
41
42
  }
@@ -3,6 +3,8 @@ const WebpackShellPluginNext = require('webpack-shell-plugin-next');
3
3
  const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin');
4
4
 
5
5
  module.exports = env => {
6
+ // Unique config for jahia's server-side source code (components using server side rendering)
7
+ // Those components have access to jahia's custom types and functions (https://academy.jahia.com/documentation/jahia/jahia-8/developer/javascript-module-development/javascript-modules-reference-documentation)
6
8
  const config = {
7
9
  entry: {
8
10
  main: path.resolve(__dirname, 'src/index')
@@ -11,10 +13,12 @@ module.exports = env => {
11
13
  path: path.resolve(__dirname, 'dist')
12
14
  },
13
15
  externals: {
16
+ // Those libraries are supplied to webpack at runtime (by the npm-module-engine project), and are not packaged in the output bundle
14
17
  '@jahia/js-server-core': 'jsServerCoreLibraryBuilder.getLibrary()',
15
18
  handlebars: 'jsServerCoreLibraryBuilder.getSharedLibrary(\'handlebars\')'
16
19
  },
17
20
  plugins: [
21
+ // This plugin help you to attach extra files or dirs to webpack's watch system
18
22
  new ExtraWatchWebpackPlugin({
19
23
  files: [
20
24
  'src/**/*',
@@ -35,11 +39,25 @@ module.exports = env => {
35
39
  devtool: 'inline-source-map'
36
40
  };
37
41
 
42
+ // 'jahia-pack' is a custom jahia script that makes a tgz package of the module's bundle
43
+ if (env.pack) {
44
+ config.plugins.push(
45
+ // This plugin allows you to run any shell commands before or after webpack builds.
46
+ new WebpackShellPluginNext({
47
+ onAfterDone: {
48
+ scripts: ['yarn jahia-pack']
49
+ }
50
+ })
51
+ );
52
+ }
53
+
54
+ // 'jahia-deploy' is a custom jahia script that makes a tgz package of the module's bundle and deploy it to jahia via curl.
38
55
  if (env.deploy) {
39
56
  config.plugins.push(
57
+ // This plugin allows you to run any shell commands before or after webpack builds.
40
58
  new WebpackShellPluginNext({
41
59
  onAfterDone: {
42
- scripts: ['yarn jahia-deploy pack']
60
+ scripts: ['yarn jahia-deploy']
43
61
  }
44
62
  })
45
63
  );