Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.20.0 release branch (ESM migration) #815

Merged
merged 11 commits into from
Dec 18, 2021
Merged

0.20.0 release branch (ESM migration) #815

merged 11 commits into from
Dec 18, 2021

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Dec 4, 2021

Related Issue

resolves #532 (continuation of #707)

Summary of Changes

  1. Migrated await entirely from ESM, including all specs and (most) dependencies
  2. make all exports explicit by making them named exports #551
  3. have init lock step initial version to current Greenwood version #816
  4. switch to c8 for ESM code coverage #818
  5. favor using latest when documenting npx commands #821
  6. add a section on scripts and imports to the docs section #822
  7. release v0.20.0 blog post #825

Alpha Release Test Plan

I think given the impact of this change, it would be wise for us to cut from a release branch instead of merging right into main so that

  • we can test this in the wild first and ensure all our docs / examples / refactoring is correct
  • we're not stuck with broken code in master while under pressure to fix things

The plan would be to test against the following projects / workflows as alpha releases are iterated upon:

  1. greenwood-getting-started - upgrade to v0.20.0-alpha.0 and node 14 greenwood-getting-started#53
  2. projectevergreen.github.io - upgrade to v0.20.0-alpha.0 and node 14 projectevergreen.github.io#73
  3. thegreehouse.io - upgrade to v0.20.0-alpha.0 and node 14 thegreenhouseio/www.thegreenhouse.io#253
  4. contributary.community - upgrade to v0.20.0-alpha.0 and node 14 ContributaryCommunity/www.contributary.community#103
  5. analogstudios.net - upgrade to v0.20.0-alpha.0 and node 14 AnalogStudiosRI/www.analogstudios.net#53
  6. greenwood-starter-presentation - upgrade to v0.20.0-alpha.0 and node 14 thescientist13/greenwood-starter-presentation#53
  7. npx - 0.20.0 release branch (ESM migration) #815 (comment)
  8. npx @greenwood/init - 0.20.0 release branch (ESM migration) #815 (comment)
  9. Stackblitz - 0.20.0 release branch (ESM migration) #815 (comment)

This PR should NOT be squashed merged though when merging into master.

TODOs

  1. Update init package.json to start from 0.20.0 - have init lock step initial version to current Greenwood version #816
  2. Restore Babel plugin extend feature + test case - restore support for extending babel configuration #817
  3. Update GitHub Actions and project to min version Node v14 - Node 14x minimum version #721
  4. Restore Test Coverage (NYC) - switch to c8 for ESM code coverage #818
  5. alpha.1
  6. Can we also resolve...? Mostly!
  7. Review and apply this guide if applicable
  8. Getting Started logo image not showing up on Stackblitz - saving changes (leading to forked stackblitz) breaks static asset image serving stackblitz/webcontainer-core#493
  9. alpha.2 ?
  10. Issue Tracking
  11. Blog post - release v0.20.0 blog post #825

@thescientist13
Copy link
Member Author

thescientist13 commented Dec 5, 2021

Cool, so testing for additional use cases is also working

npx

"Home Page Test"

npx @greenwood/cli develop

Screen Shot 2021-12-05 at 1 33 45 PM

Serve and Custom config (requires package.json, FYI)

npx @greenwood/cli serve

Screen Shot 2021-12-05 at 1 41 36 PM

init

Now It works!
Screen Shot 2021-12-11 at 1 43 49 PM

my-app % npx @greenwood/init@latest --yarn
Need to install the following packages:
  @greenwood/init@latest
Ok to proceed? (y) y
-------------------------------------------------------
Initialize Greenwood Template ♻️
-------------------------------------------------------
Yarn Enabled
Initialzing project with files...
Creating manifest (package.json)...
Installing project dependencies...
yarn install v1.22.11
info No lockfile found.
[1/4] 🔍  Resolving packages...
warning @greenwood/cli > markdown-toc > gray-matter > [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
warning @greenwood/cli > markdown-toc > remarkable > autolinker > [email protected]: Removed event-stream from gulp-header
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
✨  Done in 15.92s.
Initializing new project complete!
owenbuckley@Owens-MBP-2 my-app % yarn why @greenwood/cli
yarn why v1.22.11
[1/4] 🤔  Why do we have the module "@greenwood/cli"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "@greenwood/[email protected]"
info Has been hoisted to "@greenwood/cli"
info This module exists because it's specified in "devDependencies".
info Disk size without dependencies: "284KB"
info Disk size with unique dependencies: "272.23MB"
info Disk size with transitive dependencies: "306.19MB"
info Number of shared dependencies: 34
✨  Done in 0.65s.
owenbuckley@Owens-MBP-2 my-app % yarn serve
yarn run v1.22.11
$ greenwood serve
-------------------------------------------------------
Welcome to Greenwood (v0.20.0-alpha.1) ♻️
-------------------------------------------------------
Running Greenwood with the serve command.
Initializing project config
Initializing project workspace contexts
Generating graph of workspace files...
Started local development server at localhost:1984
Prerendering pages at http://127.0.0.1:1984
pages to render
 src/pages/index.md
 404.html
prerendering page... /
prerendering page... /404/
prerendering complete for page /.
prerendering complete for page /404/.
done prerendering all pages
copying file... .greenwood/graph.json
Initializing project config
Initializing project workspace contexts
Generating graph of workspace files...
Started production test server at localhost:8080

But because of #809 , user's are getting an ESM greenwood.config.js and package.json

% cat greenwood.config.js
export default {
  title: 'My Project'
};

% cat package.json
{
  "name": "my-app",
  "version": "1.0.0",
  "description": "",
  "type": "module",
  "scripts": {
    "start": "greenwood develop",
    "build": "greenwood build",
    "serve": "greenwood serve"
  },
  "devDependencies": {
    "@greenwood/cli": "^0.18.0"
  },
  "license": "ISC"
}

But are getting the older CJS version of Greenwood, which of course will fail

% npm ls @greenwood/cli
[email protected] /Users/owenbuckley/Desktop/my-app
└── @greenwood/[email protected]

owenbuckley@Owens-MBP-2 my-app % npm run start

> [email protected] start /Users/owenbuckley/Desktop/my-app
> greenwood develop

-------------------------------------------------------
Welcome to Greenwood (v0.18.0) ♻️
-------------------------------------------------------
Running Greenwood with the develop command.
Initializing project config
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/owenbuckley/Desktop/my-app/greenwood.config.js
require() of ES modules is not supported.
require() of /Users/owenbuckley/Desktop/my-app/greenwood.config.js from /Users/owenbuckley/Desktop/my-app/node_modules/@greenwood/cli/src/lifecycles/config.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename greenwood.config.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/owenbuckley/Desktop/my-app/package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1085:13)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at Module.require (internal/modules/cjs/loader.js:957:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at /Users/owenbuckley/Desktop/my-app/node_modules/@greenwood/cli/src/lifecycles/config.js:57:29
    at new Promise ()
    at readAndMergeConfig (/Users/owenbuckley/Desktop/my-app/node_modules/@greenwood/cli/src/lifecycles/config.js:51:10)
    at /Users/owenbuckley/Desktop/my-app/node_modules/@greenwood/cli/src/lifecycles/compile.js:16:34
    at new Promise () {
  code: 'ERR_REQUIRE_ESM'
}

Simple solution for now, for this PR, is to just manually set the version in package.json in the init package template.

Stackblitz ✅

For some reason the logo image doesn't load when running npm start, but otherwise everything seems to be working as expected? (greenwood develop works finally locally if the git repo is cloned and run locally)
Screen Shot 2021-12-05 at 2 01 26 PM

Note sure if at all related to either of these issues?


Seems to be an issue with Stackblitz itself? I can reproduce even on the 0.19.0 version, and only when saving and having the blitz forked.

* WIP

* init upgrade graphql plugin to ESM

* fix linting

* got develop command working for the website

* build command WIP

* migrate node module utils to async and refactor require to import.meta

* pass linter

* remove comment

* www/ greenwood build command working

* PostCSS working for both develop and build

* PostCSS working for both develop and build

* async prodServer support

* fix serve task not resolving standard web assets

* restore plugin analyzer

* restore plugin analyzer

* restore unified markdown functionality

* fix missed merge conflict

* restore include HTML plugin

* restore polyfills plugin

* PostCSS 8 deps upgrades

* CLI build default spec passing via ESM

* migrtate all CLI specs to ESM and enable eject

* fix spec

* migrate init package specs to ESM

* migrate google and polyfills plugins and specs to ESM

* migrate plugin-include-html to ESM

* migrate plugin import CSS, JSON, and CommonJS and their specs to ESM

* migrate plugin GraphQL and test cases to ESM

* migrate plugin GraphQL and unit tests to ESM

* migrate plugin typescript and specs to ESM

* migrate plugin postcss specs to ESM

* migrate plugin babel and default spec case to ESM

* update package READMEs for ESM

* update docs to demonstrate ESM usage

* fix linting

* handle path seperator to fix failing spec

* bug/issue 532 esm upgrade with fix for windows (#814)

* fix greenwood compilation for windows

* serve and devekop commands working

* default spec passing

* proper URL to path handling for cross platform support

* all specs passing wiht initial URL refactoring

* refactor all specs to new standard URL usage

* update docs

* fix develop command

* wip passing all specs on windows

* all commands and tests passing on windows

* update theme pack docs
* align nodejs versions

* update version

* update and rebase with release branch
* have init lock step initial version to current Greenwood version

* set minimum version as formality in template package.json

* grammar
* switch to c8 for ESM code coverage

* set new thresholds
@thescientist13 thescientist13 merged commit 86ebee0 into master Dec 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment