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

Conversation

sachinraja
Copy link
Contributor

Removes the importing of all plugins in src/util/resolveConfig to avoid importing CSS.
Import the built plugin list file instead.
resolves #4681

Removes the importing of all plugins in src/util/resolveConfig to avoid importing CSS.
Import the built plugin list file instead.
scripts/create-plugin-list.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Comment on lines 1 to 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'),
`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.

package.json Outdated Show resolved Hide resolved
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
@adamwathan adamwathan merged commit c0ee520 into tailwindlabs:master Jun 23, 2021
@adamwathan
Copy link
Member

Thanks, I'll publish a new release with this fix today 👍🏻 Long-term though it's still way better to not have this stuff in your client-side bundle at all. You can look at the tailwindcss.com repo if you want to see how we do this ourselves with preval. resolveConfig carries with it some really big dependencies you don't want to ship to the client.

@Francismori7
Copy link

Francismori7 commented Jun 23, 2021

This actually prevents npm or yarn from installing on my system:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'generate:plugin-list'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v12.16.3
4 verbose run-script [
4 verbose run-script   'pregenerate:plugin-list',
4 verbose run-script   'generate:plugin-list',
4 verbose run-script   'postgenerate:plugin-list'
4 verbose run-script ]
5 info lifecycle tailwindcss@2.2.3~pregenerate:plugin-list: tailwindcss@2.2.3
6 info lifecycle tailwindcss@2.2.3~generate:plugin-list: tailwindcss@2.2.3
7 verbose lifecycle tailwindcss@2.2.3~generate:plugin-list: unsafe-perm in lifecycle true
8 verbose lifecycle tailwindcss@2.2.3~generate:plugin-list: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\morfra\Documents\PhpstormProjects\francism.dev\node_modules\tailwindcss\node_modules\.bin;C:\Users\morfra\Documents\PhpstormProjects\francism.dev\node_modules\.bin;C:\Users\morfra\AppData\Local\Temp\yarn--1624474860949-0.8032720436669438;C:\Users\morfra\Documents\PhpstormProjects\francism.dev\node_modules\tailwindcss\node_modules\.bin;C:\Users\morfra\AppData\Local\Yarn\Data\link\node_modules\.bin;C:\Program Files\libexec\lib\node_modules\npm\bin\node-gyp-bin;C:\Program Files\lib\node_modules\npm\bin\node-gyp-bin;C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\morfra\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\morfra\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Python27;C:\Python27\Scripts;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\PuTTY;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Git\cmd;C:\Users\morfra\AppData\Local\Microsoft\WindowsApps;C:\Users\morfra\AppData\Local\GitHubDesktop\bin;C:\php;C:\ProgramData\ComposerSetup\bin;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Yarn\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\Webex\Plugins;C:\Program Files\nodejs;C:\Program Files\Redis;C:\Program Files (x86)\Microsoft Group Policy\Windows 10 May 2020 Update (2004)\PolicyDefinitions;C:\Program Files (x86)\PivotPrograms\CMS\Backup;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\SQLite;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\speedtest;C:\Program Files (x86)\Windows Kits\10\Microsoft Application Virtualization\Sequencer;C:\ngrok;C:\Program Files (x86)\Admin Arsenal\PDQ Inventory;C:\Program Files (x86)\Admin Arsenal\PDQ Deploy;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Users\morfra\.windows-build-tools\python27;C:\Users\morfra\AppData\Local\Microsoft\WindowsApps;C:\Users\morfra\AppData\Local\GitHubDesktop\bin;C:\Users\morfra\AppData\Roaming\Composer\vendor\bin;C:\Users\morfra\AppData\Local\Yarn\bin;C:\Program Files\PostgreSQL\12\bin;C:\Stripe;C:\Users\morfra\AppData\Roaming\npm;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\SQLite;C:\Users\morfra\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\GitHub CLI;C:\ngrok;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle tailwindcss@2.2.3~generate:plugin-list: CWD: C:\Users\morfra\Documents\PhpstormProjects\francism.dev\node_modules\tailwindcss
10 silly lifecycle tailwindcss@2.2.3~generate:plugin-list: Args: [ '/d /s /c', 'babel-node scripts/create-plugin-list.js' ]
11 silly lifecycle tailwindcss@2.2.3~generate:plugin-list: Returned: code: 1  signal: null
12 info lifecycle tailwindcss@2.2.3~generate:plugin-list: Failed to exec generate:plugin-list script
13 verbose stack Error: tailwindcss@2.2.3 generate:plugin-list: `babel-node scripts/create-plugin-list.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:310:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:310:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid tailwindcss@2.2.3
15 verbose cwd C:\Users\morfra\Documents\PhpstormProjects\francism.dev\node_modules\tailwindcss
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "generate:plugin-list"
18 verbose node v12.16.3
19 verbose npm  v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error tailwindcss@2.2.3 generate:plugin-list: `babel-node scripts/create-plugin-list.js`
22 error Exit status 1
23 error Failed at the tailwindcss@2.2.3 generate:plugin-list script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Edit: Using Node v12. Same result with Node V14:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'generate:plugin-list'
1 verbose cli ]
2 info using npm@6.14.13
3 info using node@v14.17.1
4 verbose run-script [
4 verbose run-script   'pregenerate:plugin-list',
4 verbose run-script   'generate:plugin-list',
4 verbose run-script   'postgenerate:plugin-list'
4 verbose run-script ]
5 info lifecycle tailwindcss@2.2.3~pregenerate:plugin-list: tailwindcss@2.2.3
6 info lifecycle tailwindcss@2.2.3~generate:plugin-list: tailwindcss@2.2.3
7 verbose lifecycle tailwindcss@2.2.3~generate:plugin-list: unsafe-perm in lifecycle true
8 verbose lifecycle tailwindcss@2.2.3~generate:plugin-list: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\morfra\Documents\PhpstormProjects\francism.dev\node_modules\tailwindcss\node_modules\.bin;C:\Users\morfra\Documents\PhpstormProjects\francism.dev\node_modules\.bin;C:\Users\morfra\AppData\Local\Temp\yarn--1624475564636-0.09291337317124859;C:\Users\morfra\Documents\PhpstormProjects\francism.dev\node_modules\tailwindcss\node_modules\.bin;C:\Users\morfra\AppData\Local\Yarn\Data\link\node_modules\.bin;C:\Program Files\libexec\lib\node_modules\npm\bin\node-gyp-bin;C:\Program Files\lib\node_modules\npm\bin\node-gyp-bin;C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\morfra\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\morfra\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Python27;C:\Python27\Scripts;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\PuTTY;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Git\cmd;C:\Users\morfra\AppData\Local\Microsoft\WindowsApps;C:\Users\morfra\AppData\Local\GitHubDesktop\bin;C:\php;C:\ProgramData\ComposerSetup\bin;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Yarn\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\Webex\Plugins;C:\Program Files\nodejs;C:\Program Files\Redis;C:\Program Files (x86)\Microsoft Group Policy\Windows 10 May 2020 Update (2004)\PolicyDefinitions;C:\Program Files (x86)\PivotPrograms\CMS\Backup;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\SQLite;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\speedtest;C:\Program Files (x86)\Windows Kits\10\Microsoft Application Virtualization\Sequencer;C:\ngrok;C:\Program Files (x86)\Admin Arsenal\PDQ Inventory;C:\Program Files (x86)\Admin Arsenal\PDQ Deploy;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Users\morfra\.windows-build-tools\python27;C:\Users\morfra\AppData\Local\Microsoft\WindowsApps;C:\Users\morfra\AppData\Local\GitHubDesktop\bin;C:\Users\morfra\AppData\Roaming\Composer\vendor\bin;C:\Users\morfra\AppData\Local\Yarn\bin;C:\Program Files\PostgreSQL\12\bin;C:\Stripe;C:\Users\morfra\AppData\Roaming\npm;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\SQLite;C:\Users\morfra\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\GitHub CLI;C:\ngrok;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle tailwindcss@2.2.3~generate:plugin-list: CWD: C:\Users\morfra\Documents\PhpstormProjects\francism.dev\node_modules\tailwindcss
10 silly lifecycle tailwindcss@2.2.3~generate:plugin-list: Args: [ '/d /s /c', 'babel-node scripts/create-plugin-list.js' ]
11 silly lifecycle tailwindcss@2.2.3~generate:plugin-list: Returned: code: 1  signal: null
12 info lifecycle tailwindcss@2.2.3~generate:plugin-list: Failed to exec generate:plugin-list script
13 verbose stack Error: tailwindcss@2.2.3 generate:plugin-list: `babel-node scripts/create-plugin-list.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:375:28)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:375:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid tailwindcss@2.2.3
15 verbose cwd C:\Users\morfra\Documents\PhpstormProjects\francism.dev\node_modules\tailwindcss
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "generate:plugin-list"
18 verbose node v14.17.1
19 verbose npm  v6.14.13
20 error code ELIFECYCLE
21 error errno 1
22 error tailwindcss@2.2.3 generate:plugin-list: `babel-node scripts/create-plugin-list.js`
22 error Exit status 1
23 error Failed at the tailwindcss@2.2.3 generate:plugin-list script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@sachinraja
Copy link
Contributor Author

sachinraja commented Jun 23, 2021

Breaks mine too. Quick fix would be to remove the install script. @adamwathan. Strange because I actually created a discussion over at the NPM repository and was told to use this.

@LeoniePhiline
Copy link

#4784

@sachinraja sachinraja deleted the resolve-config-fix branch October 14, 2021 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Next.js errors Global CSS cannot be imported from within node_modules when importing tailwindcss/resolveConfig
5 participants