@jahia/vite-plugin 0.5.5 → 0.6.0

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.
package/README.md CHANGED
@@ -2,11 +2,9 @@
2
2
 
3
3
  A Vite plugin to develop JavaScript Modules for the Jahia platform.
4
4
 
5
- This README will be updated soon.
6
-
7
5
  ## Installation
8
6
 
9
- Using our project creation CLI should set you up correctly. It will ship with good defaults to get you started, but your workflow might need more advanced settings. For that, the `jahia` Vite plugin can take an object of options:
7
+ Using our [project creation CLI (@jahia/create-module)](https://www.npmjs.com/package/@jahia/create-module) should set you up correctly. It will ship with good defaults to get you started, but your workflow might need more advanced settings. For that, the `jahia` Vite plugin can take an object of options:
10
8
 
11
9
  ```js
12
10
  import { defineConfig } from "vite";
@@ -18,10 +16,14 @@ export default defineConfig({
18
16
  jahia({
19
17
  // Client options
20
18
  client: {
21
- input: "./src/client/index.js",
22
- // /!\ This path is currently hard-coded in the engine loader,
23
- // it cannot be changed yet.
24
- output: "./javascript/client/index.js",
19
+ input: {
20
+ // Parent directory of client-side code
21
+ dir: "./src/client",
22
+ // Glob pattern to match all client-side code in dir
23
+ glob: "**‍/*.jsx",
24
+ }
25
+ // Output directory for client-side code
26
+ output: "./javascript/client/",
25
27
  },
26
28
 
27
29
  // Server options
@@ -31,6 +33,7 @@ export default defineConfig({
31
33
  output: {
32
34
  dir: "./javascript/server",
33
35
  fileName: "index", // Will produce index.js and index.css
36
+ // A known bug causes the css file to be named style.css regardless of this setting
34
37
  },
35
38
  },
36
39
 
package/dist/index.js CHANGED
@@ -1,11 +1,10 @@
1
1
  import multiEntry from '@rollup/plugin-multi-entry';
2
- import path$1 from 'node:path';
2
+ import path from 'node:path';
3
3
  import { styleText } from 'node:util';
4
4
  import { globSync } from 'tinyglobby';
5
5
  import { print } from 'esrap';
6
6
  import { walk } from 'zimmerframe';
7
7
  import { createFilter } from '@rollup/pluginutils';
8
- import path from 'path';
9
8
 
10
9
  var sharedLibs = {
11
10
  // React ships as CJS, so we need our own shims
@@ -29,7 +28,6 @@ const insertFilename = (root, prefix) => {
29
28
  const ast = walk(this.parse(code), null, {
30
29
  // Only target `export default function`
31
30
  ExportDefaultDeclaration(node) {
32
- if (node.declaration.type !== "FunctionDeclaration") return;
33
31
  return {
34
32
  // export default
35
33
  type: "ExportDefaultDeclaration",
@@ -49,11 +47,8 @@ const insertFilename = (root, prefix) => {
49
47
  property: { type: "Identifier", name: "defineProperty" }
50
48
  },
51
49
  arguments: [
52
- {
53
- // Original function
54
- ...node.declaration,
55
- type: "FunctionExpression"
56
- },
50
+ // Convert function and class declarations to expressions, keep others as is
51
+ node.declaration.type === "FunctionDeclaration" ? { ...node.declaration, type: "FunctionExpression" } : node.declaration.type === "ClassDeclaration" ? { ...node.declaration, type: "ClassExpression" } : node.declaration,
57
52
  { type: "Literal", value: "__filename" },
58
53
  {
59
54
  // { value: id, enumerable: false }
@@ -91,14 +86,10 @@ const insertFilename = (root, prefix) => {
91
86
 
92
87
  const external = Object.keys(sharedLibs);
93
88
  function buildSuccessPlugin(callback) {
94
- let succeeded = true;
95
89
  return {
96
90
  name: "build-success-callback",
97
- buildEnd(error) {
98
- succeeded = !error;
99
- },
100
- async closeBundle() {
101
- if (succeeded) await callback();
91
+ async closeBundle(error) {
92
+ if (!error) await callback();
102
93
  }
103
94
  };
104
95
  }
@@ -137,7 +128,7 @@ function jahia(options = {}) {
137
128
  build: {
138
129
  lib: {
139
130
  entry: Object.fromEntries(
140
- clientEntries.map((file) => [file, path$1.join(clientBaseDir, file)])
131
+ clientEntries.map((file) => [file, path.join(clientBaseDir, file)])
141
132
  ),
142
133
  formats: ["es"]
143
134
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/vite-plugin",
3
- "version": "0.5.5",
3
+ "version": "0.6.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com:Jahia/javascript-modules.git",
@@ -12,6 +12,9 @@
12
12
  "types": "./dist/index.d.ts",
13
13
  "import": "./dist/index.js"
14
14
  },
15
+ "files": [
16
+ "dist"
17
+ ],
15
18
  "scripts": {
16
19
  "build": "pkgroll && publint"
17
20
  },
@@ -27,7 +30,7 @@
27
30
  "@types/node": "^22.13.5",
28
31
  "pkgroll": "^2.11.0",
29
32
  "publint": "^0.3.6",
30
- "rollup": "^4.34.8",
33
+ "rollup": "^4.35.0",
31
34
  "vite": "^6.1.1"
32
35
  },
33
36
  "peerDependencies": {
package/node/node DELETED
Binary file
@@ -1,26 +0,0 @@
1
- BSD 2-Clause License
2
-
3
- For Yarn software
4
-
5
- Copyright (c) 2016-present, Yarn Contributors. All rights reserved.
6
-
7
- Redistribution and use in source and binary forms, with or without modification,
8
- are permitted provided that the following conditions are met:
9
-
10
- * Redistributions of source code must retain the above copyright notice, this
11
- list of conditions and the following disclaimer.
12
-
13
- * Redistributions in binary form must reproduce the above copyright notice,
14
- this list of conditions and the following disclaimer in the documentation
15
- and/or other materials provided with the distribution.
16
-
17
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,60 +0,0 @@
1
- <p align="center">
2
- <a href="https://yarnpkg.com/">
3
- <img alt="Yarn" src="https://github.com/yarnpkg/assets/blob/master/yarn-kitten-full.png?raw=true" width="546">
4
- </a>
5
- </p>
6
-
7
- <p align="center">
8
- Fast, reliable, and secure dependency management.
9
- </p>
10
-
11
- <p align="center">
12
- <a href="https://circleci.com/gh/yarnpkg/yarn"><img alt="Circle Status" src="https://circleci.com/gh/yarnpkg/yarn.svg?style=shield&circle-token=5f0a78473b0f440afb218bf2b82323cc6b3cb43f"></a>
13
- <a href="https://ci.appveyor.com/project/kittens/yarn/branch/master"><img alt="Appveyor Status" src="https://ci.appveyor.com/api/projects/status/0xdv8chwe2kmk463?svg=true"></a>
14
- <a href="https://dev.azure.com/yarnpkg/yarn/_build"><img alt="Azure Pipelines status" src="https://dev.azure.com/yarnpkg/yarn/_apis/build/status/Yarn%20Acceptance%20Tests"></a>
15
- <a href="https://discord.gg/yarnpkg"><img alt="Discord Chat" src="https://img.shields.io/discord/226791405589233664.svg"></a>
16
- <a href="http://commitizen.github.io/cz-cli/"><img alt="Commitizen friendly" src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg"></a>
17
- </p>
18
-
19
- ---
20
-
21
- **Fast:** Yarn caches every package it has downloaded, so it never needs to download the same package again. It also does almost everything concurrently to maximize resource utilization. This means even faster installs.
22
-
23
- **Reliable:** Using a detailed but concise lockfile format and a deterministic algorithm for install operations, Yarn is able to guarantee that any installation that works on one system will work exactly the same on another system.
24
-
25
- **Secure:** Yarn uses checksums to verify the integrity of every installed package before its code is executed.
26
-
27
- ## Features
28
-
29
- * **Offline Mode.** If you've installed a package before, then you can install it again without an internet connection.
30
- * **Deterministic.** The same dependencies will be installed in the same exact way on any machine, regardless of installation order.
31
- * **Network Performance.** Yarn efficiently queues requests and avoids request waterfalls in order to maximize network utilization.
32
- * **Network Resilience.** A single request that fails will not cause the entire installation to fail. Requests are automatically retried upon failure.
33
- * **Flat Mode.** Yarn resolves mismatched versions of dependencies to a single version to avoid creating duplicates.
34
- * **More emojis.** 🐈
35
-
36
- ## Installing Yarn
37
-
38
- Read the [Installation Guide](https://yarnpkg.com/en/docs/install) on our website for detailed instructions on how to install Yarn.
39
-
40
- ## Using Yarn
41
-
42
- Read the [Usage Guide](https://yarnpkg.com/en/docs/usage) on our website for detailed instructions on how to use Yarn.
43
-
44
- ## Contributing to Yarn
45
-
46
- Contributions are always welcome, no matter how large or small. Substantial feature requests should be proposed as an [RFC](https://github.com/yarnpkg/rfcs). Before contributing, please read the [code of conduct](CODE_OF_CONDUCT.md).
47
-
48
- See [Contributing](https://yarnpkg.com/org/contributing/).
49
-
50
- ## Prior art
51
-
52
- Yarn wouldn't exist if it wasn't for excellent prior art. Yarn has been inspired by the following projects:
53
-
54
- - [Bundler](https://github.com/bundler/bundler)
55
- - [Cargo](https://github.com/rust-lang/cargo)
56
- - [npm](https://github.com/npm/cli)
57
-
58
- ## Credits
59
-
60
- Thanks to [Sam Holmes](https://github.com/samholmes) for donating the npm package name!
@@ -1,35 +0,0 @@
1
- #!/bin/sh
2
- argv0=$(echo "$0" | sed -e 's,\\,/,g')
3
- basedir=$(dirname "$(readlink "$0" || echo "$argv0")")
4
-
5
- case "$(uname -s)" in
6
- Darwin) basedir="$( cd "$( dirname "$argv0" )" && pwd )";;
7
- Linux) basedir=$(dirname "$(readlink -f "$0" || echo "$argv0")");;
8
- *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
9
- *MSYS*) basedir=`cygpath -w "$basedir"`;;
10
- esac
11
-
12
- command_exists() {
13
- command -v "$1" >/dev/null 2>&1;
14
- }
15
-
16
- if command_exists node; then
17
- if [ "$YARN_FORCE_WINPTY" = 1 ] || command_exists winpty && test -t 1; then
18
- winpty node "$basedir/yarn.js" "$@"
19
- else
20
- exec node "$basedir/yarn.js" "$@"
21
- fi
22
- ret=$?
23
- # Debian and Ubuntu use "nodejs" as the name of the binary, not "node", so we
24
- # search for that too. See:
25
- # https://lists.debian.org/debian-devel-announce/2012/07/msg00002.html
26
- # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=614907
27
- elif command_exists nodejs; then
28
- exec nodejs "$basedir/yarn.js" "$@"
29
- ret=$?
30
- else
31
- >&2 echo 'Yarn requires Node.js 4.0 or higher to be installed.'
32
- ret=1
33
- fi
34
-
35
- exit $ret
@@ -1,2 +0,0 @@
1
- @echo off
2
- node "%~dp0\yarn.js" %*
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /* eslint-disable no-var */
4
- /* eslint-disable flowtype/require-valid-file-annotation */
5
- 'use strict';
6
-
7
- var ver = process.versions.node;
8
- var majorVer = parseInt(ver.split('.')[0], 10);
9
-
10
- if (majorVer < 4) {
11
- console.error('Node version ' + ver + ' is not supported, please use Node.js 4.0 or higher.');
12
- process.exit(1); // eslint-disable-line no-process-exit
13
- } else {
14
- try {
15
- require(__dirname + '/../lib/v8-compile-cache.js');
16
- } catch (err) {
17
- // We don't have/need this on legacy builds and dev builds
18
- }
19
-
20
- // Just requiring this package will trigger a yarn run since the
21
- // `require.main === module` check inside `cli/index.js` will always
22
- // be truthy when built with webpack :(
23
- // `lib/cli` may be `lib/cli/index.js` or `lib/cli.js` depending on the build.
24
- var cli = require(__dirname + '/../lib/cli');
25
- if (!cli.autoRun) {
26
- cli.default().catch(function(error) {
27
- console.error(error.stack || error.message || error);
28
- process.exitCode = 1;
29
- });
30
- }
31
- }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- require('./yarn.js');
@@ -1,2 +0,0 @@
1
- @echo off
2
- "%~dp0\yarn.cmd" %*