area17 / blast

Storybook for Laravel Blade 🚀
https://dev.to/area17/getting-started-with-blast-storybook-for-laravel-blade-c5c
Apache License 2.0
262 stars 37 forks source link

`blast:publish`: Uncaught SyntaxError: "undefined" is not valid JSON #97

Closed johnbacon closed 10 months ago

johnbacon commented 10 months ago

When running blade:publish, a JavaScript error is present in main.5538a5c7.iframe.bundle.js (link):

VM2768:1 Uncaught SyntaxError: "undefined" is not valid JSON
    at JSON.parse (<anonymous>)
    at ./.storybook/preview.js-generated-config-entry.js (main.5538a5c7.iframe.bundle.js:1:15462)
    at __webpack_require__ (runtime~main.1e62e197.iframe.bundle.js:1:381)
    at __webpack_exec__ (main.5538a5c7.iframe.bundle.js:1:64322)
    at main.5538a5c7.iframe.bundle.js:1:65443
    at __webpack_require__.O (runtime~main.1e62e197.iframe.bundle.js:1:1015)
    at main.5538a5c7.iframe.bundle.js:1:65586
    at webpackJsonpCallback (runtime~main.1e62e197.iframe.bundle.js:1:5873)
    at main.5538a5c7.iframe.bundle.js:1:69

That line refers to STORYBOOK_VIEWPORTS as the culprit (viewports: JSON.parse(process.env.STORYBOOK_VIEWPORTS)).

As far as I can tell, the Publish command doesn't provide viewport information, and possibly other information as well. (It looks like it hasn't been updated for a couple of years.)

blade:publish output php artisan blast:publish 0/3 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░] Reusing npm dependencies... 1/3 [▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░] Generating Stories... 2/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░] Starting static Storybook build... > @area17/blast@1.0.0 build-storybook > storybook build -o storybook-static @storybook/cli v7.1.1 info => Cleaning outputDir: /storybook-static info => Loading presets info => Building manager.. WARN unable to find package.json for @prettier/plugin-php WARN unable to find package.json for eslint WARN unable to find package.json for eslint-config-prettier WARN unable to find package.json for eslint-plugin-prettier WARN unable to find package.json for husky WARN unable to find package.json for lint-staged WARN unable to find package.json for stylelint WARN unable to find package.json for stylelint-config-recommended WARN unable to find package.json for stylelint-order WARN unable to find package.json for stylelint-prettier info => Manager built (1.28 s) info => Compiling preview.. info => Copying static files: /e/server/gigsalad-laravel/laravel/vendor/area17/blast/node_modules/@storybook/manager/static at /e/server/gigsalad-laravel/laravel/vendor/area17/blast/storybook-static/sb-common-assets info Addon-docs: using MDX2 info => Using implicit CSS loaders info => Using default Webpack5 setup info => Preview built (17 s) WARN export 'default' (imported as 'previewAnnotations') was not found in '/e/server/gigsalad-laravel/laravel/vendor/area17/blast/node_modules/@storybook/addon-a11y/dist/preview.mjs' (module has no exports) WARN export 'default' (imported as 'previewAnnotations') was not found in '/e/server/gigsalad-laravel/laravel/vendor/area17/blast/node_modules/@storybook/addon-essentials/dist/actions/preview.mjs' (possible exports: argsEnhancers) WARN export 'default' (imported as 'previewAnnotations') was not found in '/e/server/gigsalad-laravel/laravel/vendor/area17/blast/node_modules/@storybook/addon-essentials/dist/backgrounds/preview.mjs' (possible exports: decorators, globals, parameters) WARN export 'default' (imported as 'previewAnnotations') was not found in '/e/server/gigsalad-laravel/laravel/vendor/area17/blast/node_modules/@storybook/addon-essentials/dist/docs/preview.mjs' (possible exports: parameters) WARN export 'default' (imported as 'previewAnnotations') was not found in '/e/server/gigsalad-laravel/laravel/vendor/area17/blast/node_modules/@storybook/addon-essentials/dist/highlight/preview.mjs' (possible exports: highlightObject, highlightStyle) WARN export 'default' (imported as 'previewAnnotations') was not found in '/e/server/gigsalad-laravel/laravel/vendor/area17/blast/node_modules/@storybook/addon-essentials/dist/measure/preview.mjs' (possible exports: decorators, globals) WARN export 'default' (imported as 'previewAnnotations') was not found in '/e/server/gigsalad-laravel/laravel/vendor/area17/blast/node_modules/@storybook/addon-essentials/dist/outline/preview.mjs' (possible exports: decorators, globals) WARN export 'default' (imported as 'previewAnnotations') was not found in '/e/server/gigsalad-laravel/laravel/vendor/area17/blast/node_modules/@storybook/addon-links/dist/preview.mjs' (possible exports: decorators) WARN export 'default' (imported as 'previewAnnotations') was not found in '/e/server/gigsalad-laravel/laravel/vendor/area17/blast/node_modules/@storybook/server/preview.js' (possible exports: parameters, render, renderToCanvas) WARN asset size limit: The following asset(s) exceed the recommended size limit (244 KiB). WARN This can impact web performance. WARN Assets: WARN 964.bc4fb6f7.iframe.bundle.js (986 KiB) WARN 644.10db7075.iframe.bundle.js (583 KiB) WARN 115.4267b1f8.iframe.bundle.js (584 KiB) info => Output directory: /e/server/gigsalad-laravel/laravel/vendor/area17/blast/storybook-static 3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] Copying static build to `/public/storybook-static`.. 3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] Publish Complete
mrtimbrook commented 10 months ago

Yeah it's missing the viewport information. I've been working on this this week and I should have the fix up tomorrow

johnbacon commented 10 months ago

Perfect, thank you!

mrtimbrook commented 10 months ago

Fixed in https://github.com/area17/blast/releases/tag/1.9.1