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

npm run package stucks when there's a component with <style lang="sass"> #13159

Open
anafro opened this issue Dec 14, 2024 · 2 comments
Open
Labels
pkg:svelte-package Issues related to svelte-package

Comments

@anafro
Copy link

anafro commented Dec 14, 2024

Describe the bug

I try to npm run package, and it stucks if there are components in /src/lib that contains <style lang="sass">:

PS D:\tools\ui> npm run package

> @anfr/[email protected] package
> svelte-kit sync && svelte-package && publint

If bundling, conditions should include development or production. If not bundling, conditions or NODE_ENV should include development or production. See https://www.npmjs.com/package/esm-env for tips on setting conditions in popular bundlers and runtimes.
src\lib -> dist

If I remove all the components with sass style tag, it gets built. For example, if we leave just Box.svelte and Text.svelte which don't have sass styles inside.

If there is a <style> tag (without lang attribute), it gets built.

// svelte.config.js
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	// Consult https://svelte.dev/docs/kit/integrations
	// for more information about preprocessors
	preprocess: vitePreprocess(),

	kit: {
		// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
		// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
		// See https://svelte.dev/docs/kit/adapters for more information about adapters.
		adapter: adapter()
	}
};

export default config;
// vite.config.ts
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';

export default defineConfig({
	plugins: [sveltekit()],
});

The package.json content:

{
	"name": "@anfr/ui",
	"version": "1.0.0",
	"description": "The Svelte component library for Anafro tools",
	"keywords": [
		"svelte",
		"svelte-components",
		"svelte-component-library",
		"ui",
		"ui-components",
		"anafro",
		"anafro-tools"
	],
	"homepage": "https://github.com/anafro/ui",
	"author": {
		"name": "Anatoly Frolov",
		"email": "[email protected]",
		"url": "https://anafro.ru"
	},
	"scripts": {
		"dev": "vite dev",
		"build": "vite build && npm run package",
		"preview": "vite preview",
		"package": "svelte-kit sync && svelte-package && publint",
		"prepublishOnly": "npm run package",
		"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
		"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
	},
	"files": [
		"dist",
		"!dist/**/*.test.*",
		"!dist/**/*.spec.*"
	],
	"sideEffects": [
		"**/*.css"
	],
	"svelte": "./dist/index.js",
	"types": "./dist/index.d.ts",
	"type": "module",
	"exports": {
		".": {
			"types": "./dist/index.d.ts",
			"svelte": "./dist/index.js"
		}
	},
	"peerDependencies": {
		"svelte": "^5.0.0"
	},
	"devDependencies": {
		"@sveltejs/adapter-auto": "^3.3.1",
		"@sveltejs/kit": "^2.11.1",
		"@sveltejs/package": "^2.3.7",
		"@sveltejs/vite-plugin-svelte": "^5.0.2",
		"publint": "^0.2.12",
		"sass-embedded": "^1.83.0",
		"svelte": "^5.12.0",
		"svelte-check": "^4.1.1",
		"typescript": "^5.7.2",
		"vite": "^6.0.3"
	},
	"dependencies": {
		"npm-check-updates": "^17.1.11",
		"svelte-preprocess-sass": "^2.0.1"
	}
}

Reproduction

https://github.com/anafro/ui

Logs

(none)

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 1.01 GB / 7.88 GB
  Binaries:
    Node: 20.16.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @sveltejs/adapter-auto: ^3.3.1 => 3.3.1
    @sveltejs/kit: ^2.11.1 => 2.11.1
    @sveltejs/package: ^2.3.7 => 2.3.7
    @sveltejs/vite-plugin-svelte: ^5.0.2 => 5.0.2
    svelte: ^5.12.0 => 5.12.0
    vite: ^6.0.3 => 6.0.3

Severity

blocking all usage of SvelteKit

Additional Information

(none)

@anafro
Copy link
Author

anafro commented Dec 15, 2024

I also tried to create a new project, created a component with lang="sass" styles, did the npm install -D sass-embedded, and it fails to package: the packaging process is frozen. The last line shown is: src\lib -> dist. And it never goes away

I think you can reproduce this issue this way

@eltigerchino eltigerchino added the pkg:svelte-package Issues related to svelte-package label Dec 16, 2024
@anafro
Copy link
Author

anafro commented Dec 17, 2024

Temporary Fix

Replace vitePreprocess() with sveltePreprocess({ sass: true }) in Svelte config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:svelte-package Issues related to svelte-package
Projects
None yet
Development

No branches or pull requests

2 participants