Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 23 additions & 26 deletions Resources/Private/Build/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
## Working with GULP, NPM, and DDEV
# Working with esbuild, npm, and DDEV

Follow these steps to build fresh JS files:
Follow these steps to build fresh JavaScript files for the maps2 extension.

- *Step 1: Access the DDEV Container*
## Step 1: Access the DDEV Container

If you're working locally with DDEV, you need to jump into the DDEV container
using the following command:
If you are working locally with DDEV, ssh into the DDEV web container:

```
ddev ssh
```
```bash
ddev ssh
```

- *Step 2: Navigate to the 'maps2' folder*
## Step 2: Navigate to the Build Directory

Use the 'cd' command to change the current working directory to the `maps2`
folder:
Change your current working directory to the Build folder of the `maps2` extension:

```
cd [pathOfMaps2]/Resouces/Private/Build
```
```bash
cd [pathOfMaps2]/Resources/Private/Build
```

- *Step 3: Install Necessary Tools*
## Step 3: Install Dependencies

Execute the following command to install necessary tools like `gulp`
and `typescript`:
Execute the following command to install the required build tools (like `esbuild`) and frontend libraries:

```
npm install
```
```bash
npm install
```

- *Step 4: Build/Compile JS Files & Move them to the appropriate Directory*
## Step 4: Build and Compile JavaScript Files

Use the 'gulp' command to build/compile and move the resulting JS files into
the `Resources/Public/JavaScript` folder:
Run the custom build script using Node.js. This will compile, bundle, and minify the JavaScript files and move them directly into the `Resources/Public/JavaScript/` folder:

```bash
node build.js
```

```
./node_modules/.bin/gulp
```
53 changes: 53 additions & 0 deletions Resources/Private/Build/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const esbuild = require('esbuild');
const path = require('path');

// Base options shared across all build tasks
const baseOptions = {
minify: true,
sourcemap: true,
target: 'es2020',
outdir: '../../Public/JavaScript',
};

async function runBuild() {
try {
// 1. Leaflet Bundle via stdin (enforces strict concatenation order)
await esbuild.build({
...baseOptions,
bundle: true,
// Simulate a JS entry point that loads the three scripts sequentially
stdin: {
contents: `
require('leaflet/dist/leaflet.js');
require('leaflet.path.drag/src/Path.Drag.js');
require('leaflet-editable/src/Leaflet.Editable.js');
`,
resolveDir: __dirname, // Tells esbuild where to locate node_modules
},
outfile: path.join(baseOptions.outdir, 'leaflet.min.js'),
// Remove outdir here since outfile is explicitly set
outdir: undefined,
});

// 2. TYPO3 JavaScript Modules (Native ESM, NO bundling!)
await esbuild.build({
...baseOptions,
bundle: false,
format: 'esm', // Preserves native "import/export" statements for the browser
entryPoints: {
'Classes': 'JavaScript/Classes.js',
'GoogleMapsModule.min': 'JavaScript/GoogleMapsModule.js',
'OpenStreetMapModule.min': 'JavaScript/OpenStreetMapModule.js',
'GoogleMaps2.min': 'JavaScript/GoogleMaps2.js',
'OpenStreetMap2.min': 'JavaScript/OpenStreetMap2.js',
},
});

console.log('🎉 Build completed successfully!');
} catch (err) {
console.error('❌ Build failed:', err);
process.exit(1);
}
}

runBuild();
83 changes: 0 additions & 83 deletions Resources/Private/Build/gulpfile.js

This file was deleted.

Loading
Loading