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

Remove the PostCSS process #909

Merged
merged 2 commits into from
Feb 2, 2024
Merged
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
48 changes: 0 additions & 48 deletions DEPRECATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,54 +36,6 @@ export class ApplicationController extends Controller {

-- [Replacing Component Helper.md](https://github.com/embroider-build/embroider/blob/main/docs/replacing-component-helper.md#when-youre-invoking-a-component-youve-been-given)

## PostCSS process

Currently, the addon's CSS is run through PostCSS by default, which will create static
fallbacks for all custom properties using their defaults. It also provides the option `excludeCSS` so you can import the uncompiled addon styles in your project's `app/styles/app.css` and run your own PostCSS using `postcss-import`:

```js
// before
let app = new EmberApp(defaults, {
'ember-promise-modals': {
excludeCSS: true,
},
});

return maybeEmbroider(app);
```

This functionality no longer stands in Embroider world because [v2 addons are static](https://github.com/embroider-build/embroider/blob/HEAD/docs/spec.md). When installed in your app, they don't do anything at build-time.

As most browsers have been supporting CSS variables for several years, the v2 addon will no longer process the CSS and the components will import the non-processed styles. However, if you still need the static fallbacks `postcss-preset-env` used to generate, you can re-implement the functionality on the app side with a [Webpack config](https://webpack.js.org/loaders/postcss-loader/). For instance:

```js
let app = new EmberApp(defaults, {});

return maybeEmbroider(app, {
packagerOptions: {
webpackConfig: {
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [['postcss-preset-env', { stage: 3 }]],
},
},
},
],
},
],
},
},
},
});
```

## Ember < 3.28 & node < 16 support

The v2 addon will no longer support Ember versions lower than 3.28.
Expand Down
40 changes: 38 additions & 2 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
# Migration

## From 0.x.x to 1.x.x
## From v4.x.x to v5.x.x (PostCSS process)

Version 1.0.0 replaced the ember-animated powered animations with CSS based animations. In addition to that the default animation was also changed. This guide will show you how to get the animations of the old version.
Until version 4.x.x, ember-promise-modals ran through PostCSS by default, to create static fallbacks for all custom properties using their defaults. This functionality has been removed from 5.x.x because it doesn't fit well with Embroider ecosystem: [v2 addons are static](https://github.com/embroider-build/embroider/blob/HEAD/docs/spec.md). When installed in your app, they don't do anything at build-time. Also, most browsers have been supporting CSS variables for several years.

However, if you still need the static fallbacks `postcss-preset-env` used to generate, you can re-implement the functionality on the app side with a [Webpack config](https://webpack.js.org/loaders/postcss-loader/). For instance:

```js
let app = new EmberApp(defaults, {});

return maybeEmbroider(app, {
packagerOptions: {
webpackConfig: {
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [['postcss-preset-env', { stage: 3 }]],
},
},
},
],
},
],
},
},
},
});
```

Additionally, until version 4.x.x, ember-promise-modal provided the option `excludeCSS` so you can import the uncompiled addon styles in your project's `app/styles/app.css` and run your own PostCSS using `postcss-import`. In any case, ember-promise-modal CSS is expected to be included in your app in one way or the other. For this reason, there's no equivalent to `excludeCSS` in the v2 addon: components import statically the CSS they require, which means no `@import` statement in your `app/styles/app.css` is necessary, and you are still able to process the style as explained above.
BlueCutOfficial marked this conversation as resolved.
Show resolved Hide resolved

## From 0.x.x to 1.x.x (animations)

Version 1.0.0 replaced the ember-animated powered animations with CSS-based animations. In addition to that the default animation was also changed. This guide will show you how to get the animations of the old version.

### From top/bottom animations

Expand Down
31 changes: 4 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,32 +198,6 @@ for how the modals are opened in your JavaScript actions and look at
[app.css](./tests/dummy/app/styles/app.css) for the style definition of these
custom animations.

### CSS Variables

⚠️ This functionality will be removed in 5.0.0, checkout the [DEPRECATIONS.md]('https://github.com/mainmatter/ember-promise-modals/blob/main/DEPRECATIONS.md#postcss-process) guide.

The addons CSS is run through PostCSS by default, which will create static
fallbacks for all custom properties using their defaults.

If your application uses PostCSS by itself, you can set `excludeCSS` to `true`
inside your `ember-cli-build.js`:

```js
let app = new EmberAddon(defaults, {
// Add options here
'ember-promise-modals': {
excludeCSS: true,
},
});
```

Done that, you can use [postcss-import](https://github.com/postcss/postcss-import)
to import the uncompiled addon styles in your projects `app/styles/app.css`:

```css
@import 'ember-promise-modals';
```

## Accessibility

User can press the <kbd>Esc</kbd> key to close the modal.
Expand Down Expand Up @@ -309,7 +283,10 @@ module('Application | ...', function (hooks) {

## Migration guide

See the [Migration](MIGRATION.md) guide for details.
See the [Migration](MIGRATION.md) guide for details:

- From 0.x.x to 1.x.x about the replacement of ember-animated powered animations with CSS-based animations.
- From v4.x.x to v5.x.x about the removal of the PostCSS process.

## Contributing

Expand Down
40 changes: 0 additions & 40 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,5 @@
'use strict';

const funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
const BroccoliPostCSS = require('broccoli-postcss');
const postcssPresetEnv = require('postcss-preset-env');

const pkg = require('./package.json');

module.exports = {
name: require('./package').name,

treeForAddon() {
const tree = this._super(...arguments);
const app = this._findHost();
const options = typeof app.options === 'object' ? app.options : {};
const addonConfig = options[pkg.name] || {};

const addonWithoutStyles = funnel(tree, {
exclude: ['**/*.css'],
});

if (addonConfig.excludeCSS === true) {
return addonWithoutStyles;
}

const addonStyles = funnel(tree, {
include: ['**/*.css'],
});

const processedStyles = new BroccoliPostCSS(addonStyles, {
plugins: [
{
module: postcssPresetEnv,
options: {
stage: 3,
overrideBrowserslist: app.project._targets.browsers,
},
},
],
});

return mergeTrees([addonWithoutStyles, processedStyles]);
},
};
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,16 @@
"dependencies": {
"@ember/test-waiters": "^3.0.2",
"@embroider/util": "^1.7.1",
"broccoli-funnel": "^3.0.8",
"broccoli-merge-trees": "^4.2.0",
"broccoli-postcss": "^6.0.1",
"ember-auto-import": "^2.4.2",
"ember-cli-babel": "^7.26.11",
"ember-cli-htmlbars": "^6.0.1",
"focus-trap": "^6.9.3",
"postcss-preset-env": "^7.6.0"
"focus-trap": "^6.9.3"
},
"devDependencies": {
"@babel/eslint-parser": "7.23.10",
"@ember/optional-features": "2.0.0",
"@ember/string": "3.1.1",
"@ember/test-helpers": "2.9.4",
"@ember/test-helpers": "3.2.1",
"@embroider/macros": "1.13.4",
"@embroider/test-setup": "3.0.3",
"@release-it-plugins/lerna-changelog": "5.0.0",
Expand Down
Loading
Loading