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

Generate plugin list file #4725

Merged
merged 5 commits into from Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Expand Up @@ -4,3 +4,4 @@
/peers
/tests/fixtures/cli-utils.js
/stubs/*
/src/corePluginList.js
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -15,3 +15,6 @@ yarn-error.log

# Perf related files
isolate*.log

# Generated files
/src/corePluginList.js
34 changes: 22 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -23,6 +23,7 @@
"postbabelify": "ncc build lib/cli-peer-dependencies.js -o peers",
"rebuild-fixtures": "npm run babelify && babel-node scripts/rebuildFixtures.js",
"prepublishOnly": "npm install --force && npm run babelify && babel-node scripts/build.js && node scripts/build-plugins.js",
"prepare": "babel-node scripts/create-plugin-list.js",
sachinraja marked this conversation as resolved.
Show resolved Hide resolved
"style": "eslint .",
"test": "cross-env TAILWIND_MODE=build jest",
"test:integrations": "npm run test --prefix ./integrations",
Expand Down
10 changes: 10 additions & 0 deletions scripts/create-plugin-list.js
@@ -0,0 +1,10 @@
import * as corePlugins from '../src/plugins'
import fs from 'fs'
import path from 'path'

const corePluginList = Object.keys(corePlugins)

fs.writeFileSync(
path.join(__dirname, '..', 'src', 'corePluginList.js'),
sachinraja marked this conversation as resolved.
Show resolved Hide resolved
`export default ${JSON.stringify(corePluginList)}`
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Since this logic is only used by resolveConfig.js can we not generate the file and directly move this to resolveConfig.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make it so we would have to commit a generated file to the repo. It would also have to conform to the linter. Is this desired behavior?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant something more similar to the older logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused as to what this means. We cannot do this in resolveConfig.js because it would mean a package consumer would have to import all the plugins and thus import CSS from the preflight plugin. See linked issue for why this is a problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since exports are transpiled to commonjs, there may exist some trick to get a list of all of them. Just suppositions though.

4 changes: 2 additions & 2 deletions src/util/resolveConfig.js
Expand Up @@ -10,7 +10,7 @@ import toPath from 'lodash/toPath'
import head from 'lodash/head'
import isPlainObject from 'lodash/isPlainObject'
import negateValue from './negateValue'
import * as corePlugins from '../plugins'
import corePluginList from '../corePluginList'
import configurePlugins from './configurePlugins'
import defaultConfig from '../../stubs/defaultConfig.stub'
import colors from '../../colors'
Expand Down Expand Up @@ -243,7 +243,7 @@ function resolveCorePlugins(corePluginConfigs) {
return corePluginConfig({ corePlugins: resolved })
}
return configurePlugins(corePluginConfig, resolved)
}, Object.keys(corePlugins))
}, corePluginList)

return result
}
Expand Down