Giter Club home page Giter Club logo

Comments (17)

aralroca avatar aralroca commented on June 15, 2024 1

@devongovett can be related with the files in package.json?

"files": [
"node/*.js",
"node/*.mjs",
"node/*.d.ts",
"node/*.flow"
],

In this code, looks that there are dependencies of other files:

if (process.env.CSS_TRANSFORMER_WASM) {
module.exports = require(`../pkg`);
} else {
try {
module.exports = require(`lightningcss-${parts.join('-')}`);
} catch (err) {
module.exports = require(`../lightningcss.${parts.join('-')}.node`);
}
}

At least:

  • pkg/*
  • node/*.node

However, I see that these files do not exist in the repo either... Are they generated during the build or how does it work? Thanks

from lightningcss.

useEffects avatar useEffects commented on June 15, 2024

same issue with turborepo

from lightningcss.

cayquesilva avatar cayquesilva commented on June 15, 2024

same with expo / react-native.

from lightningcss.

aralroca avatar aralroca commented on June 15, 2024

same issue with Bun.build

from lightningcss.

aralroca avatar aralroca commented on June 15, 2024

@mercer08 did you find some workaround?

from lightningcss.

devongovett avatar devongovett commented on June 15, 2024

The problem is that your package manager (eg npm) is not installing the optional dependencies in the package. There is a dependency per os/cpu architecture that should be installed. The error you see here is because we attempt to fall back to a local version if the those packages are not found (for local development).

You'll need to check why your package manager is not working properly. It could be:

  1. You have the --no-optional flag enabled, which would prevent installing optional dependencies.
  2. You're running on an unsupported platform.
  3. A bug in your package manager (eg npm/cli#4828). Try deleting node_modules and your package lock file and installing again.

from lightningcss.

aralroca avatar aralroca commented on June 15, 2024

Probably is more related with 2. You're running on an unsupported platform.. This happens after build a CLI, and this CLI can be used on any platform to build the files using Bun.build and lightningcss, but lightningcss lib is included in the bundle, and the problems comes after this CLI build.

Running Bun.build with lightningcss in runtime without the CLI it works.

Probably the same is happening to @mercer08 that comments that is happening in the build process.

from lightningcss.

devongovett avatar devongovett commented on June 15, 2024

What platform are you running on? That means operating system/cpu.

from lightningcss.

aralroca avatar aralroca commented on June 15, 2024

What platform are you running on? That means operating system/cpu.

  • uname -mprs: Darwin 23.4.0 arm64 arm
  • Chip: Apple M1 Pro
  • Memory: 16 GB
  • macOS: 14.4.1 (23E224)

from lightningcss.

devongovett avatar devongovett commented on June 15, 2024

Then you're definitely on a supported platform. Your package manager isn't working properly. It should be installing lightningcss-darwin-arm64.

from lightningcss.

aralroca avatar aralroca commented on June 15, 2024

I'm using bun as a package manager, and it install all dependencies, devDependencies, andoptionalDependencies. Without doing the build of my CLI, it works. The problem comes when generating the build that probably does not add the optionalDependencies inside the final code. I'm still investigating and see if this is it, but thanks for your feedback @devongovett.

from lightningcss.

usamasulaiman avatar usamasulaiman commented on June 15, 2024

I am using Yarn berry with pnp. It does install the optional dependencies appropriately (lightningcss-darwin-arm64 for m1 mac) but I still get the error on the relative ../pkg path line. Is getting the optional dependencies installed enough here in this case. Would you recommend doing something more? @devongovett

from lightningcss.

devongovett avatar devongovett commented on June 15, 2024

hmm now looking at the code, it seems that is also behind an environment variable check. Is that somehow set on your system?

https://github.com/parcel-bundler/lightningcss/blob/baa1a2b7fa52eeb3827f8edcc2e14de33cd69ad0/node/index.js#L15C5-L15C37

from lightningcss.

Jon-a-than avatar Jon-a-than commented on June 15, 2024

I have same problem.

I'm not sure if this is a problem with lightningcss. I can reproduce the problem in the following way.

It seems to be caused by the side effects of the vite package.

image
image

$ pnpm ls
Legend: production dependency, optional only, dev only

[email protected] F:\...\vite-lightningcss (PRIVATE)

devDependencies:
lightningcss 1.25.0
typescript 5.4.5
vite 5.2.11

$ pnpm -v
9.1.2

image

from lightningcss.

th-m avatar th-m commented on June 15, 2024

I am seeing this issue using nx and react / vite apps.

from lightningcss.

brsc2909 avatar brsc2909 commented on June 15, 2024

Anyone have a workaround for this yet?

from lightningcss.

DominicDolan avatar DominicDolan commented on June 15, 2024

I had this issue and I found it was caused from importing from lightningcss in a runtime file

I accidentally had this in a file that was running in the browser:

import {transform} from "lightningcss"

When I removed it, it worked

from lightningcss.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.