Skip to content

Css extraction issue with transpiled code #620

@pksorensen

Description

@pksorensen

I have used my project (quickform-core) in another project and used css extraction without problems. But in a new project i am just hitting my head against the wall for hours now not able to figure out why.

my next.config.js


import { env } from "process";

import { withGriffelCSSExtraction } from '@griffel/next-extraction-plugin';

/** @type {import('next').NextConfig} */
const nextConfig =  {
    output: env.NODE_ENV === "production" ? 'standalone' : undefined,
    compress: false,
    experimental: {
        instrumentationHook: true,
        swcPlugins: [['fluentui-next-appdir-directive', { paths: ['@griffel', '@fluentui', '@eavfw'] }]],
    },
    transpilePackages: ["@fluentui/react-components", '@eavfw/quickform-core', '@eavfw/quickform-input-select', '@eavfw/query'],
 

    webpack(config) {
        config.module.rules.unshift({
            test: /\.(js|jsx)$/,
            exclude: /node_modules/,
            use: [
                {
                    loader: '@griffel/webpack-loader',
                },
            ],
        });

        // If your project uses TypeScript
        config.module.rules.unshift({
            test: /\.(ts|tsx)$/,
            exclude: /node_modules/,
            use: [
                {
                    loader: '@griffel/webpack-loader',
                    options: {
                        babelOptions: {
                            presets: [
                                "next/babel"
                            ]
                        },
                    },
                },
            ],
        });
       
        return config;
    },
     
};

export default withGriffelCSSExtraction()(nextConfig);

and i am getting the below error. I tried to identify the difference between my working project and the new project, but so far they are very similar.

Any hint to help me find the root cause would be nice.

@EAVFW\quickform-core is basically a bunch of typescritp files distributed by npm

./src/components/quickform/GroupOnlineQuickform.tsx
C:\dev\go\qp\node_modules\@eavfw\quickform-core\src\index.ts:1
(function (exports) { export * from "./components";
                      ^^^^^^

SyntaxError: Unexpected token 'export'
    at new Script (node:vm:117:7)
    at Module.evaluate (C:\dev\go\qp\node_modules\@linaria\babel-preset\lib\module.js:280:20)
    at require.Object.assign.ensure (C:\dev\go\qp\node_modules\@linaria\babel-preset\lib\module.js:214:13)
    at C:\dev\go\qp\apps\GroupOnline.QuotationPlatformHost\src\components\quickform-container\goTokens.tsx:4:22
    at C:\dev\go\qp\apps\GroupOnline.QuotationPlatformHost\src\components\quickform-container\goTokens.tsx:17:3
    at Script.runInContext (node:vm:149:12)
    at Module.evaluate (C:\dev\go\qp\node_modules\@linaria\babel-preset\lib\module.js:283:12)
    at require.Object.assign.ensure (C:\dev\go\qp\node_modules\@linaria\babel-preset\lib\module.js:214:13)
    at C:\dev\go\qp\apps\GroupOnline.QuotationPlatformHost\src\components\quickform\GroupOnlineQuickform.tsx:3:17
    at C:\dev\go\qp\apps\GroupOnline.QuotationPlatformHost\src\components\quickform\GroupOnlineQuickform.tsx:40:3
    at Script.runInContext (node:vm:149:12)
    at Module.evaluate (C:\dev\go\qp\node_modules\@linaria\babel-preset\lib\module.js:283:12)
    at evaluate (C:\dev\go\qp\node_modules\@griffel\babel-preset\src\utils\evaluatePathsInVM.js:22:9)
    at evaluatePathsInVM (C:\dev\go\qp\node_modules\@griffel\babel-preset\src\utils\evaluatePathsInVM.js:80:21)
    at evaluatePaths (C:\dev\go\qp\node_modules\@griffel\babel-preset\src\utils\evaluatePaths.js:22:51)
    at PluginPass.exit (C:\dev\go\qp\node_modules\@griffel\babel-preset\src\transformPlugin.js:186:59)
    at newFn (C:\dev\go\qp\node_modules\@babel\traverse\lib\visitors.js:172:14)
    at NodePath._call (C:\dev\go\qp\node_modules\@babel\traverse\lib\path\context.js:49:20)
    at NodePath.call (C:\dev\go\qp\node_modules\@babel\traverse\lib\path\context.js:39:18)
    at NodePath.visit (C:\dev\go\qp\node_modules\@babel\traverse\lib\path\context.js:96:8)
    at TraversalContext.visitQueue (C:\dev\go\qp\node_modules\@babel\traverse\lib\context.js:90:16)
    at TraversalContext.visitSingle (C:\dev\go\qp\node_modules\@babel\traverse\lib\context.js:66:19)
    at TraversalContext.visit (C:\dev\go\qp\node_modules\@babel\traverse\lib\context.js:113:19)
    at traverseNode (C:\dev\go\qp\node_modules\@babel\traverse\lib\traverse-node.js:22:17)
    at traverse (C:\dev\go\qp\node_modules\@babel\traverse\lib\index.js:53:34)
    at transformFile (C:\dev\go\qp\node_modules\@babel\core\lib\transformation\index.js:82:31)
    at transformFile.next (<anonymous>)
    at run (C:\dev\go\qp\node_modules\@babel\core\lib\transformation\index.js:24:12)
    at run.next (<anonymous>)
    at C:\dev\go\qp\node_modules\@babel\core\lib\transform-ast.js:23:33
    at Generator.next (<anonymous>)
    at evaluateSync (C:\dev\go\qp\node_modules\gensync\index.js:251:28)
    at sync (C:\dev\go\qp\node_modules\gensync\index.js:89:14)
    at stopHiding - secret - don't use this - v1 (C:\dev\go\qp\node_modules\@babel\core\lib\errors\rewrite-stack-trace.js:47:12)
    at Object.transformFromAstSync (C:\dev\go\qp\node_modules\@babel\core\lib\transform-ast.js:43:83)
    at transformSync (C:\dev\go\qp\node_modules\@griffel\webpack-loader\src\transformSync.js:21:35)
    at Object.webpackLoader (C:\dev\go\qp\node_modules\@griffel\webpack-loader\src\webpackLoader.js:80:52)

Import trace for requested module:
./src/components/quickform/GroupOnlineQuickform.tsx


> Build failed because of webpack errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions