Skip to content

Commit

Permalink
alpha version doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pdallmer committed Aug 21, 2024
1 parent 1840db7 commit 1101fad
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 17 deletions.
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ callouts:
warning:
title: Warning
color: red
note:
title: Note
color: yellow

23 changes: 7 additions & 16 deletions documentation/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ parent: Documentation
---

## Configuration
You can configure the project in `/ssjs.config.js`.
You can configure the project in `/ssjs.config.js`.
### output
This is the name of the output file.
**default: "main.js"**
### package
Setting `package: true` will create a Package for the SFMC package manager. The package contains a Cloudpage Collection and a single JSON Code Resource or landingpage (if html loader was used). This option is useful for deployments, after the code has been tested.\
**default: false**
Expand All @@ -28,18 +31,6 @@ This option sets the output name of the cloudpage collection file file (if packa
### codeResourceName
This option sets the output name of the code resource file file (if package is set to true).
**default: ssjs-code-resource**
### replacements
This option defines replacement patterns for the output file. This can be useful if standard webpack loaders add code that is not compatible with SSJS.
**default:**
```js
[
{
pattern: /JSON.strinigfy/gi,
replacement: "Stringify",
},
{
pattern: /JSON.parse/gi,
replacement: "Platform.Function.ParseJSON",
},
]
```
### dynamicPolyfills
This option defines if dynamic polyfills are used. This is currently only available in alpha releases.
**default: false**
52 changes: 52 additions & 0 deletions documentation/dynamicPolyfills.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
layout: default
title: Dynamic Polyfills
nav_order: 9
parent: Documentation
---

## Dynamic Polyfills

{: .note }
This is an experimental feature. To use it, install the alpha version by running `npm install --global generator-ssjs@alpha`.

Dynamic Polyfills enable you to use modern JS functions without importing the polyfills. Instead the polyfills will be added from the plugin if the functions are detected. the dynamic polyfills also don't break the core lobrary, as they will transform the functions to prevent updating the prototype.

**example:**
input:
```javascript
[1,2,3].map(e => e * 2);
```

output:
```javascript
function arrayMap(array, callbackFn) {
var arr = [];
for (var i = 0; i < array.length; i++) {
arr.push(callbackFn(array[i], i, array));
}
return arr;
}
;
/******/(function () {
// webpackBootstrap
var __webpack_exports__ = {};
arrayMap([1, 2, 3], function (e) {
return e * 2;
});
/******/
})();
```

**available polyfills:**
* array
* filter
* forEach
* includes
* map
* reduce
* object
* keys
* values


12 changes: 11 additions & 1 deletion documentation/polyfills.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ parent: Documentation

### polyfills
Its possible to import all polyfills with a single import statement: `import polyfills`, or only the required polyfills, e.g. `import polyfills/array`, or `import polyfills/array/map`.
**available polyfills:**
* array
* filter
* forEach
* includes
* map
* reduce
* object
* keys
* values

{: .warning }
Using Polyfills breaks the core library.
Using Polyfills breaks the core library and potentially other features. You can use WsProxy and Pltform functinos as an alternative.

0 comments on commit 1101fad

Please sign in to comment.