Skip to content
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.

revert: feat(css-loader): use preload when available (#631) #645

Merged
merged 1 commit into from
Sep 17, 2020

Conversation

wincent
Copy link
Contributor

@wincent wincent commented Sep 17, 2020

This reverts commit 1423ca3, because the feature doesn't work as expected, as described in this comment.

In short, our testing showed the loader producing code that correctly inserted preload links in the head, and the network pane showed the corresponding resources being fetched, and in the right order. But the associated styles were not being applied to the DOM, leading to visual inconsistencies, as well as undesirable console spew of the form:

The resource .../css/ApplicationsMenu.css was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate as value and it is preloaded intentionally.

To fix this, we might be able to add a second, non-preload-ing link tag, but that would defeat the purpose of our original change, which was to improve our Lighthouse metrics.

So, reverting this for now. We might revisit preload for this or some other purpose in the future.

Original PR: #632

This reverts commit 1423ca3, because the feature doesn't work as
expected, as described here:

liferay-frontend/liferay-portal#345 (comment)

In short, our testing showed the loader producing code that correctly
inserted `preload` links in the `head`, and the network pane showed
the corresponding resources being fetched, and in the right order. But
the associated styles were not being applied to the DOM, leading to
visual inconsistencies, as well as undesirable console spew of the form:

> The resource .../css/ApplicationsMenu.css was preloaded using link
> preload but not used within a few seconds from the window's load
> event. Please make sure it has an appropriate `as` value and it is
> preloaded intentionally.

To fix this, we might be able to add a second, non-`preload`-ing `link`
tag, but that would defeat the purpose of our original change, which was
to improve our Lighthouse metrics.

So, reverting this for now. We might revisit `preload` for this or some
other purpose in the future.

Original PR: #632
@wincent
Copy link
Contributor Author

wincent commented Sep 17, 2020

Simple revert, and I have to release 821 packages before I can update liferay-portal, so I'm going to merge this.

@wincent wincent merged commit 426ac86 into master Sep 17, 2020
@wincent wincent deleted the wincent/revert branch September 17, 2020 13:29
wincent added a commit to liferay/liferay-npm-tools that referenced this pull request Sep 17, 2020
Because we need this revert:

liferay/liferay-js-toolkit#645

Done with:

    cd packages/liferay-npm-bundler-preset-liferay-dev
    yarn add \
      babel-preset-liferay-standard@2.19.2 \
      liferay-npm-bundler-loader-css-loader@2.19.2 \
      liferay-npm-bundler-plugin-{exclude-imports,inject-imports-dependencies,inject-peer-dependencies,namespace-packages,replace-browser-modules,resolve-linked-dependencies}@2.19.2
    cd ../liferay-npm-scripts
    yarn add \
      liferay-npm-bridge-generator@2.19.2 \
      liferay-npm-bundler@2.19.2

Note that we have some cross-project coupling going on here that lead to
duplicates in the yarn.lock file:

```
$ yarn why liferay-npm-bundler-plugin-resolve-linked-dependencies                                                                                 7.97s [wincent/deps] ~/code/liferay-npm-tools
[1/4] 🤔  Why do we have the module "liferay-npm-bundler-plugin-resolve-linked-dependencies"...?
=> Found "liferay-npm-bundler-plugin-resolve-linked-dependencies@2.19.2"
   - Hoisted from "_project_#liferay-npm-bundler-preset-standard#liferay-npm-bundler-plugin-resolve-linked-dependencies"
   - Hoisted from "_project_#liferay-npm-bundler-preset-liferay-dev#liferay-npm-bundler-plugin-resolve-linked-dependencies"
=> Found "liferay-theme-tasks#liferay-npm-bundler-plugin-resolve-linked-dependencies@2.19.1"
   - Hoisted from "_project_#liferay-npm-scripts#liferay-theme-tasks#liferay-npm-build-tools-common#liferay-npm-bundler-preset-standard#liferay-npm-bundler-plugin-resolve-linked-dependencies"
```

Neither `yarn` nor a `yarn install --force` were enough to get rid of
it; had to go with `rm yarn.lock && yarn`. This gets rid of the
duplicate dependencies from the liferay-js-toolkit project, but there
are a bunch of others in here still, hopefully benign (eg. look at the
`@storybook` dupes in there).
wincent added a commit to liferay/liferay-npm-tools that referenced this pull request Sep 17, 2020
Release notes:

    https://github.com/liferay/liferay-npm-tools/releases/tag/liferay-npm-bundler-preset-liferay-dev%2Fv4.6.2

Motivating change -- getting this PR, which reverts a broken feature:

    liferay/liferay-js-toolkit#645

Updated with:

    cd packages/liferay-npm-scripts
    yarn add liferay-npm-bundler-preset-liferay-dev@4.6.2
brianchandotcom pushed a commit to brianchandotcom/liferay-portal that referenced this pull request Sep 17, 2020
Release notes:

https://github.com/liferay/liferay-npm-tools/releases/tag/liferay-npm-scripts%2Fv32.6.2

Principal change of interest is this revert:

liferay/liferay-js-toolkit#645

Which removes the "preload" feature of the css-loader, because it didn't
work as intended for reasons described here:

liferay-frontend#345 (comment)

Note that even though we aren't using that feature, we are keeping the
changes from a couple of commits ago ("LPS-120199 Future-proof users of
liferay-npm-bundler-preset-standard"), because the arguments there still
apply.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant