-
Notifications
You must be signed in to change notification settings - Fork 5
feat(CLI)!: adopt ESM for blocks and themes #1482
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "@frontify/frontify-cli": major | ||
| --- | ||
|
|
||
| feat: support React 19 | ||
|
|
||
| The CLI now supports React 19 to stay up-to-date with the React ecosystem and provide better performance and modern features. | ||
| Consumers can from now on update their block / theme to React 19. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| "@frontify/frontify-cli": major | ||
| --- | ||
|
|
||
| chore: update required node to 22 | ||
|
|
||
| The minimum required Node.js version has been bumped from 18 to 22. | ||
| Node.js 18 is reaching its end-of-life. Node 22 is the current Active LTS release. | ||
| Consumers must update their local development environments and CI/CD pipelines to use Node.js version 22 or higher. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| "@frontify/frontify-cli": major | ||
| --- | ||
|
|
||
| feat: build blocks / themes as ESM packages | ||
|
|
||
| Custom blocks and themes are now compiled and output as ECMAScript Modules (ESM) instead of relying on global window variables. | ||
| ESM is the modern standard for JavaScript, offering better interoperability, tree-shaking and compatibility with modern bundlers. | ||
| Consumers don't need to do anything to migrate to ESM, but they should be aware of the changes. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
|
|
||
| ## Prerequisite | ||
|
|
||
| - Node >=16 | ||
| - Node >=22 | ||
|
|
||
| ## Installation | ||
|
|
||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,46 +1,42 @@ | ||||
| /* (c) Copyright Frontify Ltd., all rights reserved. */ | ||||
|
|
||||
| import react from '@vitejs/plugin-react'; | ||||
| import { build } from 'vite'; | ||||
| import { viteExternalsPlugin } from 'vite-plugin-externals'; | ||||
| import { build, esmExternalRequirePlugin } from 'vite'; | ||||
|
|
||||
| import { getAppBridgeVersion } from '../appBridgeVersion'; | ||||
| import { REACT_MODULES } from '../vitePlugins'; | ||||
|
|
||||
| import { type CompilerOptions } from './compilerOptions'; | ||||
|
|
||||
| export const compileBlock = async ({ projectPath, entryFile, outputName }: CompilerOptions) => { | ||||
| const appBridgeVersion = getAppBridgeVersion(projectPath); | ||||
| return build({ | ||||
| plugins: [ | ||||
| react(), | ||||
| viteExternalsPlugin({ | ||||
| react: 'React', | ||||
| 'react-dom': 'ReactDOM', | ||||
| }), | ||||
| ], | ||||
| plugins: [react(), esmExternalRequirePlugin({ external: REACT_MODULES })], | ||||
| define: { | ||||
| 'process.env.NODE_ENV': JSON.stringify('production'), | ||||
| }, | ||||
| root: projectPath, | ||||
| mode: 'production', | ||||
| build: { | ||||
| minify: 'terser', | ||||
| cssMinify: 'lightningcss', | ||||
| lib: { | ||||
| name: outputName, | ||||
| entry: entryFile, | ||||
| formats: ['iife'], | ||||
| formats: ['es'], | ||||
| fileName: () => 'index.js', | ||||
| cssFileName: 'style', | ||||
| }, | ||||
| rollupOptions: { | ||||
| external: ['react', 'react-dom'], | ||||
| output: { | ||||
| globals: { | ||||
| react: 'React', | ||||
| 'react-dom': 'ReactDOM', | ||||
| }, | ||||
| footer: ` | ||||
| window.${outputName} = ${outputName}; | ||||
| window.${outputName}.dependencies = window.${outputName}.packages || {}; | ||||
| window.${outputName}.dependencies['@frontify/app-bridge'] = '${appBridgeVersion}'; | ||||
| `, | ||||
| rolldownOptions: { | ||||
| platform: 'browser', | ||||
| treeshake: { | ||||
| // TODO: Fix in Fondue | ||||
|
Check warning on line 31 in packages/cli/src/utils/compiler/compileBlock.ts
|
||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I assume this one is fixed?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, I'll have to ask Noah to look into it |
||||
| moduleSideEffects: [ | ||||
| { test: /@frontify\/fondue-components/, sideEffects: false }, | ||||
| { test: /@frontify\/fondue-icons/, sideEffects: false }, | ||||
| { test: /@frontify\/fondue-tokens/, sideEffects: false }, | ||||
| { test: /@frontify\/fondue-charts/, sideEffects: false }, | ||||
| { test: /@frontify\/fondue-rte/, sideEffects: false }, | ||||
| { test: /\.css$/, sideEffects: true }, | ||||
| ], | ||||
| }, | ||||
| }, | ||||
| }, | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.