Skip to content

Releases: ProjectEvergreen/greenwood

v0.32.0-alpha.7

22 Mar 19:08
Compare
Choose a tag to compare

v0.32.0-alpha.6

17 Mar 18:39
Compare
Choose a tag to compare

v0.32.0-alpha.5

09 Mar 15:21
Compare
Choose a tag to compare
v0.32.0-alpha.5 Pre-release
Pre-release

Overview

This latest release in the v0.32.0 release line fixes some issue with Greenwood's types (and hopefully the last one for a while 😅 🤞 ).

# npm
$ npm i -D @greenwood/cli@alpha

# Yarn 1.x (classic)
$ yarn upgrade @greenwood/cli@alpha --dev

# pnpm
$ pnpm i -D @greenwood/cli@alpha

Changelog

https://github.com/ProjectEvergreen/greenwood/issues?q=label%3Av0.32.0-alpha.5

  1. Rollup Plugin type definition is incorrect

Breaking Changes

N / A

Known Issues

  1. TS based frontmatter imports are not working
  2. Source plugin based types are not correct

Diff

v0.32.0-alpha.4...v0.32.0-alpha.5

v0.32.0-alpha.4

09 Mar 14:27
Compare
Choose a tag to compare
v0.32.0-alpha.4 Pre-release
Pre-release

Overview

This latest release in the v0.32.0 release line fixes some issue with Greenwood's types.

NOTE: Please bump to v0.32.0-alpha.5 to get some small hot fixes with some of Greenwood's types

# npm
$ npm i -D @greenwood/cli@alpha

# Yarn 1.x (classic)
$ yarn upgrade @greenwood/cli@alpha --dev

# pnpm
$ pnpm i -D @greenwood/cli@alpha

Changelog

https://github.com/ProjectEvergreen/greenwood/issues?q=label%3Av0.32.0-alpha.4

  1. Copy plugin has the wrong type configuration

Breaking Changes

N / A

Known Issues

  1. Rollup Plugin type definition is incorrect

Diff

v0.32.0-alpha.3...v0.32.0-alpha.4

v0.32.0-alpha.3

09 Mar 02:52
Compare
Choose a tag to compare
v0.32.0-alpha.3 Pre-release
Pre-release

Overview

This latest release in the v0.32.0 release line fixes some issue with Greenwood's types.

NOTE: Please bump to v0.32.0-alpha.5 to get some small hot fixes with some of Greenwood's types

# npm
$ npm i -D @greenwood/cli@alpha

# Yarn 1.x (classic)
$ yarn upgrade @greenwood/cli@alpha --dev

# pnpm
$ pnpm i -D @greenwood/cli@alpha

Changelog

https://github.com/ProjectEvergreen/greenwood/issues?q=label%3Av0.32.0-alpha.3

  1. devServer.proxy should have been optional

Breaking Changes

N / A

Known Issues

  1. Copy plugin has the wrong type configuration

Diff

v0.32.0-alpha.2...v0.32.0-alpha.3

v0.32.0-alpha.2

09 Mar 02:06
Compare
Choose a tag to compare
v0.32.0-alpha.2 Pre-release
Pre-release

Overview

This third release in the v0.32.0 release line fixes some issue with Greenwood's types

NOTE: Please bump to v0.32.0-alpha.5 to get some small hot fixes with some of Greenwood's types

# npm
$ npm i -D @greenwood/cli@alpha

# Yarn 1.x (classic)
$ yarn upgrade @greenwood/cli@alpha --dev

# pnpm
$ pnpm i -D @greenwood/cli@alpha

Changelog

https://github.com/ProjectEvergreen/greenwood/issues?q=label%3Av0.32.0-alpha.2

  1. Fixup Greenwood types

Breaking Changes

N / A

Known Issues

  1. devServer.proxy should have been optional

Diff

v0.32.0-alpha.1...v0.32.0-alpha.2

v0.32.0-alpha.1

09 Mar 01:19
Compare
Choose a tag to compare
v0.32.0-alpha.1 Pre-release
Pre-release

Overview

This second release in the v0.32.0 release line introduces built-in TypeScript support for Greenwood, refines some of Greenwood's type definitions, frontmatter collections can now be an array, and fixes a couple of bugs.

NOTE: Please bump to v0.32.0-alpha.5 to get some small hot fixes with some of Greenwood's types

# npm
$ npm i -D @greenwood/cli@alpha

# Yarn 1.x (classic)
$ yarn upgrade @greenwood/cli@alpha --dev

# pnpm
$ pnpm i -D @greenwood/cli@alpha

Changelog

https://github.com/ProjectEvergreen/greenwood/issues?q=label%3Av0.32.0-alpha.1

  1. Built-In TypeScript support
  2. support an array for collections frontmatter key
  3. bundled static assets from node_modules not getting uploaded to Cloudflare
  4. incomplete import map generation (when there are lots of dependencies)

Features (Early Access)

TypeScript

With this release, Greenwood now provides built-in support for TypeScript, with the ability to fallback to using tsc if certain TypeScript features you're using (like Decorators, enums, namespaces, etc) are not supported through just type stripping alone. Docs are still in progress for types and TypeScript, so please see the below references for now, and please feel free to ask in Discord if you have any questions / feedback if trying this stuff out early.

You can see some example repos here:

NodeJS Version

You'll need to use version >=22.6.0 and need to set the --experimental-strip-types flag for any Greenwood commands

{
  "scripts": {
    "build": "NODE_OPTIONS='--experimental-strip-types' greenwood build"
  }
}

If you're feeling adventurous, you can use >=23.x.x and omit the flag, and keep an eye on this PR for when unflagged typestripping support may come to Node LTS 22.x 👀

TypeScript

You'll need to install typescript into your project in devDependencies

$ npm i typescript --save-dev

Configuration File

You can now author your configuration file (and plugins) in TypeScript by having a greenwood.config.ts file

import type { Config } from '@greenwood/cli';

const config: Config = {
  // ...
}

export default config;

TypeScript Plugin

If you're using Greenwood's TypeScript plugin, you can remove that from your Greenwood configuration file (as it is now considered deprecated).

tsconfig.json

You'll need these minimum settings in your tsconfig.json for compilerOptions, but feel free to add your own on top. We also recommend adding "erasableSyntaxOnly": true.

{
  "compilerOptions": {
    "module": "preserve",
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "verbatimModuleSyntax": false,
    "noEmit": true
  }
}

Type Definitions

Below are some common type definitions you can add to your project based on what features / plugins you might be using with Greenwood.

// Greenwood Raw plugin
declare module "*?type=raw" {
  const content: string;
  export default content;
}

// Greenwood CSS Modules plugin
declare module "*.module.css" {
  const classes: { [key: string]: string };
  export default classes;
}

// CSS Import Attribute
// https://github.com/microsoft/TypeScript/issues/46135
declare module "*.css" {
  const sheet: CSSStyleSheet;

  export default sheet;
}

tsc Fallback

As mentioned, built-in type-stripping may not handle all TypeScript features, or even JavaScript features like Decorators. If that's the case, you can enable the useTsc flag in your configuration file to fallback to using tsc with the full power of the TypeScript compiler.

import type { Config } from '@greenwood/cli';

const config: Config = {
  useTsc: true
};

export default config;

Breaking Changes

TypeScript Plugin

Starting with this release, the TypeScript plugin is officially considered deprecated, so please follow the above steps for integrating built-in TypeScript support into your project. When the official v0.32.0 release goes out, the package will be deprecated on NPM.

Known Issues

  1. Plugin types are broken
  2. Excessive configuration file detected logs

Diff

v0.32.0-alpha.0...v0.32.0-alpha.1

v0.32.0-alpha.0

02 Mar 19:18
Compare
Choose a tag to compare
v0.32.0-alpha.0 Pre-release
Pre-release

Overview

This first release in the v0.32.0 release line introduces types for Greenwood, an adapter plugin for AWS, and bumps the minimum required NodeJS 20.x version for stable JSON Import Attributes compatibility.

# npm
$ npm i -D @greenwood/cli@alpha

# Yarn 1.x (classic)
$ yarn upgrade @greenwood/cli@alpha --dev

# pnpm
$ pnpm i -D @greenwood/cli@alpha

Changelog

https://github.com/ProjectEvergreen/greenwood/issues?q=label%3Av0.32.0-alpha.0

  1. bump to minimum NodeJS 20.x version of 20.18.3
  2. allow greater than range for upper NodeJS minimum version in engines
  3. types support for public capabilities of Greenwood
  4. AWS Adapter plugin

Features (Early Access)

Docs are still in progress for types(script) and the AWS Adapter plugin, so please see the below references for now, and please feel free to ask in Discord if you have any questions / feedback if trying this stuff out early

Types

Greenwood now exports a number of types, which you can start using in JavaScript or TypeScript files right now, for example

// JSDoc
/** @type {import('@greenwood/cli').Config} */
// TypeScript
import type { Config } from '@greenwood/cli';

Note: Built-in TypeScript support will be coming in the next alpha, including deprecating the TypeScript plugin.

AWS Adapter

The current AWS Adapter plugin is designed to output predictable and consumable build output for your SSR pages and API routes, available at .aws-output, by simply adding the plugin to your Greenwood config

import { greenwoodPluginAdapterAws } from '@greenwood/plugin-adapter-aws';

export default {
  plugins: [
    greenwoodPluginAdapterAws()
  ]
}

You can see a couple integration examples here:

Check out this discussion around potential "presets" for this plugin.

Breaking Changes

Minimum NodeJS Version

The minimum NodeJS version on the 20.x line has been bumped to 20.18.3 which formally marks JSON Import Attributes as stable, which will remove any warning messages when running Greenwood.

Though not a breaking change, the minimum 22.x version has now been changed to have an upper bound using >= instead of ^

# before
^22.12.0

# after
>=22.12.0

Resource and Server Interface

With the introduction of types in Greenwood, the previously documented usage for creating Resource and Server plugins referenced an interface file, which was just a class to extend from, and wasn't really much of an interface at all.

In addition, you'll no longer need to do the super() call, and you'll want compilation and any options to be instance members of your own class.

For example, before you might have had:

import { ResourceInterface } from "@greenwood/cli/src/lib/resource-interface.js";

class ExampleResource extends ResourceInterface {
  constructor(compilation, options) {
    super(compilation, options);
    // ...
  }

  // ...
}

Now, you can use JSDoc based type imports and instance properties

/** @type {import('@greenwood/cli').Resource} */
class ExampleResource {
  constructor(compilation, options) {
    this.compilation = compilation;
    this.options = options;
    // ...
  }

  // ...
}

Exports Map / Module field

Though not likely a breaking change to anyone using Greenwood, as an internal change, Greenwood removed the non-standard module field from all package.json files and converted entirely to use the exports field.

// before
{
  "main": "./src/index.js",
  "module": "./src/index.js",
},
// after
{
  "main": "./src/index.js",
  "exports": {
    ".": {
      "types": "./src/types/index.d.ts",
      "import": "./src/index.js"
    }
  }
}

Known Issues

N / A

Diff

v0.31.1...v0.32.0-alpha.0

v0.31.1

13 Feb 03:20
Compare
Choose a tag to compare

Overview

This patch release fixes a couple bugs in the import map generation as well as static asset bundle handling.

# npm
$ npm i -D @greenwood/cli@latest

# Yarn 1.x (classic)
$ yarn upgrade @greenwood/cli@latest --dev

# pnpm
$ pnpm i -D @greenwood/cli@latest

Changelog

https://github.com/ProjectEvergreen/greenwood/issues?q=label%3Av0.31.1

  1. multiple usages of new URL + import.meta.url in same file only bundles the last occurrence
  2. binary asset formats (e.g. png) are getting corrupted when bundled with new URL + import.meta.url
  3. export maps with entry point only conditions are showing the condition as part of the generated import map key (ex. d3)
  4. export maps that have just an entry point are not working

Breaking Changes

N / A

Known Issues

N / A

Diff

v0.31.0...v0.31.1

v0.31.0

27 Jan 19:37
Compare
Choose a tag to compare

Overview

This new minor release v0.31.0 focuses on greater ecosystem compatibility through a significant refactor of how import maps are generated and better handling of the exports map specification, as well as how node_modules are resolved generally. This includes libraries (Shoelace, Spectrum Web Components) as well as package managers like pnpm. The minimum version of NodeJS LTS was also bumped. (see the breaking changes section of the release notes).

# npm
$ npm i -D @greenwood/cli@latest

# Yarn 1.x (classic)
$ yarn upgrade @greenwood/cli@latest --dev

# pnpm
$ pnpm i -D @greenwood/cli@latest

Changelog

https://github.com/ProjectEvergreen/greenwood/issues?q=label%3Av0.31.0

  1. improve support for package.json exports when building up import maps
  2. leverage import.meta.resolve to support import maps generation and accurate node_modules resolution when building
  3. walk package error if @spectrum-web-components/action-menu is installed even if not used
  4. support non-JavaScript file formats for import maps
  5. Improve PNPM support
  6. Import Attributes support in Acorn
  7. not all expected modern JavaScript syntax supported
  8. leverage import.meta.resolve to support import maps generation and accurate node_modules resolution when building
  9. Improve PNPM support
  10. bare CSS @import specifiers are not resolving and bundling correctly
  11. better document and clarify Lit SSR plugin usage caveats
  12. frontmatter imports not working for any format supported by a resource plugin
  13. ESM only configuration for PostCSS plugin
  14. standardize on Greenwood config as single source for prerender behavior for all renderer plugins
  15. CSS bundling optimization not handling transitive relative url(...) references
  16. update init scaffolding to use unified website Discord link
  17. unable to resolve packages with a nested package.json
  18. intermittent Response.clone: Body has already been consumed error from the dev server
  19. frontmatter content breaking graph data parsing in SSR pages
  20. none optimization setting leads to broken resource requests in production builds
  21. getting a Cannot read properties of null (reading 'rawAttrs') error
  22. data client not working on production builds (when not using prerender option)
  23. PostCSS plugin breaks bundling of SSR CSS-based import attributes
  24. SSR pages are not have resource plugin optimization lifecycles applied
  25. Upgrade minimum NodeJS LTS version
  26. bundling for CSS relative node_modules based url references breaks
  27. migrate to register function for NodeJS custom imports
  28. allow for customizable serverless nodejs runtime version for Vercel adapter
  29. Better support for (GitHub flavored) Markdown
  30. fix missing runtime key for API routes when using Vercel adapter
  31. import map generation not finding package.json for some libraries like tslib (when recursively segmenting entry point)
  32. rollup bundling failing trying to resolve directories
  33. log when API routes are being bundled
  34. import map generation cache and dedupe optimizations
  35. export map sub condition object keys with a wildcard are not resolving in the browser (condition not getting expanded)
  36. better sanitize Rollup importer for when resolving user workspace resources
  37. escaped HTML entities in markdown content are not being honored when prerendering Light DOM HTML
  38. improve import map generation diagnostics
  39. bump to latest version of puppeteer
  40. upgrade to WCC v0.16.0

Breaking Changes

NodeJS version

The new minimum versions for NodeJS are as follows

  • ^18.20.5
  • ^20.10.0
  • ^22.12.0

Import Maps (during development)

With this new version of Greenwood, our honoring of the exports spec will now be a lot more compliant and complete, but may (unintentionally) "break" some packages you might be using. In particular, one case observed where this breaks is Lit v2, which as of v3, now supports exports.

If you find any issues after upgrading, please review any diagnostics emitted by Greenwood and review the docs on our website, or check to see if there are newer versions of your package available. If you're still stuck, please reach out to us on Discord or in this GitHub discussion.

Markdown

As part of this release, we update all unified related plugins to latest. This introduced a couple user-facing breaking changes:

  1. The markdown.settings configuration option option is longer supported as it's no longer supported by remark-parse
  2. GFM (GitHub flavored markdown) was removed from remark, so make sure to bring your own, like remark-gfm, especially for things like tables

process.env.NODE_ENV

Prior to this release, Greenwood had included a behavior that would automatically replace instances of process.env.NODE_ENV in browser build output, but this was mostly for libraries like Redux that were not properly isomorphic. (process is not supported in browsers!)

Ideally packages you use should acknowledge this already, but if you still run into packages that make this assumption, you can re-create this substitution behavior using a Greenwood plugin

// greenwood.config.js
import { ResourceInterface } from '@greenwood/cli/src/lib/resource-interface.js';

class ProcessEnvReplaceResource extends ResourceInterface {
  constructor(compilation) {
    super();

    this.compilation = compilation;
  }

  async shouldIntercept(url) {
    // your custom condition goes here
    return url.pathname.endsWith('redux.mjs');
  }

  async intercept(url, request, response) {
    const body = await response.text();
    const env = process.env.__GWD_COMMAND__ === 'develop' ? 'development' : 'production';
    const contents = body.replace(/process.env.NODE_ENV/g, `"${env}"`);

    return new Response(contents, {
      headers: new Headers({
        'Content-Type': 'text/javascript',
      })
    });
  }
}

export default {
  // ...
  plugins: [{
    type: 'resource',
    name: 'process-env-replace',
    provider: (compilation) => new ProcessEnvReplaceResource(compilation)
  }]
}

WCC

There were a couple minor breaking changes in WCC, so please review the release notes to account for any changes that may impact your usage.

Node Modules

Going forward, the recommended pattern for referencing assets from your node_modules folder (that are not bare module ESM specifiers) will be to start all paths with /node_modules/. This will ensure Greenwood knows to use import.meta.resolve to find and lookup your dependency where ever it is installed based on your package managers.

Examples

@import "/node_modules/font-awesome/css/font-awesome.css";
@import "/node_modules/bootstrap/dist/css/bootstrap.css";
<script type="module" src="/node_modules/@shoelace-style/shoelace/dist/shoelace.js"></script>

PostCSS Plugin

Greenwood...

Read more