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

"TypeError: atVariables is not a function" with v0.2.0. #204

Closed
ehoogeveen opened this issue Nov 11, 2020 · 12 comments
Closed

"TypeError: atVariables is not a function" with v0.2.0. #204

ehoogeveen opened this issue Nov 11, 2020 · 12 comments

Comments

@ehoogeveen
Copy link

  • Node.js version: v14.15.0 LTS
  • postcss-at-rules-variables version: v0.2.0

After updating to the new version I get the error TypeError: atVariables is not a function.
It appears that require('postcss-at-rules-variables') now returns an object ({ default: [Function: _default], postcss: true}) where other plugins return a function ([Function (anonymous)] { postcss: true }).

I can work around the problem by using atVariables['default']() instead, but I'm not sure what the side effects of that are, if any.

@Scrum
Copy link
Owner

Scrum commented Nov 11, 2020

@ehoogeveen What version of postcss are you using?

@ehoogeveen
Copy link
Author

I tested with postcss version 8.1.7 and pocstcss-cli version 8.2.0, on Windows.

@Scrum
Copy link
Owner

Scrum commented Nov 12, 2020

I tested with postcss version 8.1.7 and pocstcss-cli version 8.2.0, on Windows.

Can you give an example or link where you get the error?

@spacedawwwg
Copy link

I just upgraded to 0.2.0 and had exactly the same issue.TypeError: i is not a function

I'm using in conjunction with postcss-mixins - I'll try throw a mini reproduction together

@ehoogeveen
Copy link
Author

That would be great, thanks. I've been meaning to make a test case but our setup is a bit arcane.

@AlexWayfer
Copy link

AlexWayfer commented Nov 19, 2020

I've faced with a similar in AlexWayfer/flame-cli#57 (I'm trying to replace SCSS with PostCSS completely, so it's not quite this PR, but based on it).

> postcss assets/styles/ -d public/styles/ --base assets/styles/ --ext=css

TypeError: require(...) is not a function
    at Object.<anonymous> (/home/alex/Projects/ruby/test/foo_bar/postcss.config.js:3:40)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at module.exports (/home/alex/Projects/ruby/test/foo_bar/node_modules/.pnpm/import-fresh@3.2.2/node_modules/import-fresh/index.js:32:59)
    at loadJs (/home/alex/Projects/ruby/test/foo_bar/node_modules/.pnpm/cosmiconfig@7.0.0/node_modules/cosmiconfig/dist/loaders.js:16:18)
    at Explorer.loadFileContent (/home/alex/Projects/ruby/test/foo_bar/node_modules/.pnpm/cosmiconfig@7.0.0/node_modules/cosmiconfig/dist/Explorer.js:84:32)
    at Explorer.createCosmiconfigResult (/home/alex/Projects/ruby/test/foo_bar/node_modules/.pnpm/cosmiconfig@7.0.0/node_modules/cosmiconfig/dist/Explorer.js:89:36)

My configuration:

// postcss.config.js

module.exports = {
	plugins: [
		// there can be more, but it's reproducible only with this package
		require('postcss-at-rules-variables')({ atRules: ['media'] })
	]
}

package.json:

	"dependencies": {
		"@babel/core": "*",
		"@babel/plugin-transform-object-assign": "*",
		"@babel/preset-env": "*",
		"@rollup/plugin-babel": "*",
		"@rollup/plugin-commonjs": "*",
		"@rollup/plugin-json": "*",
		"@rollup/plugin-node-resolve": "*",
		"autoprefixer": "*",
		"postcss-at-rules-variables": "*",
		"postcss-cli": "*",
		"postcss-flexbugs-fixes": "*",
		"postcss-mixins": "*",
		"postcss-nested": "*",
		"promise-polyfill": "*",
		"rollup": "*",
		"sass": "*",
		"simplify-js": "*",
		"whatwg-fetch": "*"
	},
	...
	"scripts": {
		"build:styles": "postcss assets/styles/ -d public/styles/ --base assets/styles/ --ext=css",
		...
	}

With version lock like this:

"postcss-at-rules-variables": "^0.1.0",

there is no such error.

@AlexWayfer
Copy link

With version lock like this:

"postcss-at-rules-variables": "^0.1.0",

there is no such error.

But it locks PostCSS at version 7, and other dependent packages too.

@Scrum
Copy link
Owner

Scrum commented Nov 20, 2020

I've faced with a similar in AlexWayfer/flame-cli#57 (I'm trying to replace SCSS with PostCSS completely, so it's not quite this PR, but based on it).

Describe the configuration OS, nodejs ?

@AlexWayfer
Copy link

I've faced with a similar in AlexWayfer/flame-cli#57 (I'm trying to replace SCSS with PostCSS completely, so it's not quite this PR, but based on it).

Describe the configuration OS, nodejs ?

Arch Linux, Node.js 15.1.0

I found simpler project: https://github.com/AlexWayfer/alexwayfer.name

@Scrum
Copy link
Owner

Scrum commented Nov 30, 2020

@ehoogeveen @spacedawwwg @AlexWayfer I made a small fix, please update the package. Let me know if it doesn't work for you.

do not hesitate to reopen the problem if your problem is not solved

@Scrum Scrum closed this as completed Nov 30, 2020
@ehoogeveen
Copy link
Author

Problem seems to be fixed for me, thanks!

@AlexWayfer
Copy link

Confirm, see no problems anymore, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants