adobe/css-tools

Can no longer import css-tools 4.1.0+ from *.mjs file

Closed this issue ยท 14 comments

When using @adobe/css-tools 4.0.1 and 4.0.2 I was able to do:

import cssTools from '@adobe/css-tools';

from my script.mjs file (executed with node script.mjs in my package.json)

Since 4.1.0 was released this no longer works and I get the error:

(node:2617) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
/Users/michaelpotter/Projects/outline/node_modules/@adobe/css-tools/dist/esm/index.js:1
export { default as parse } from './parse';

Node version is 16.16.0, which I'm stuck with on this project. For now I'm going to pin my version of cssTools to 4.0.2 but interested in how I should be using the latest version.

think it's cause of missing .js extensions as i I mentioned in #106

I added add_esm_import_extensions.mjs to the build, but it seems for the last build they did not run it.

@holblin maybe you should add a npm upload action to github? so you don't manually publish packages

@jogibear9988 it's already running as a GitHub action. As you can see here: https://github.com/adobe/css-tools/actions/runs/4238076267/jobs/7364748837#step:6:68

Though, there was an error on the last execution.

I will check @mike-potter to fix the import for all the use cases (web and node projects).

Hi @mike-potter ๐Ÿ‘‹
Could you build it locally #108 and test it?
This should solve this issue but I would like to confirm with you before merging the PR and releasing a new version.
Thanks ๐Ÿ‘

I don't really have a way to build it locally here, but if there is something I can put in my package.json to pin to a specific version or something I can do that.

Could you try version 4.3.0-beta.1?

Using 4.3.0-beta.1 I get:

import cssTools from '@adobe/css-tools';
       ^^^^^^^^
SyntaxError: The requested module '@adobe/css-tools' does not provide an export named 'default'

Hi @mike-potter could you try:
import * as cssTools from '@adobe/css-tools';

I will add a default export into a beta.2 or rc.1 but that would be great if we could validate the rest ๐Ÿ‘

I'm not sure I can validate the rest given that error. All I'm able to do is update the version of csstools and then run our script that imports it. If it can't import then the script can't continue. Let me know when you have beta.2 and I can test again.

Could you test with 4.3.0-beta.2?

Yes, beta.2 works! Thanks.

How is the 4.3.0-rc.1 @mike-potter ? Does that also work?
If so I'll release the 4.3.0.

Closed due to no-response + beta.2 was working so I expect the 4.3.0 to work too.