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

v0.1.3 Sourcemap for "..node_modules/.vite/*.js" points to missing source files #129

Closed
eddpascoal opened this issue Oct 27, 2021 · 8 comments · Fixed by #153
Closed

v0.1.3 Sourcemap for "..node_modules/.vite/*.js" points to missing source files #129

eddpascoal opened this issue Oct 27, 2021 · 8 comments · Fixed by #153

Comments

@eddpascoal
Copy link

eddpascoal commented Oct 27, 2021

Hi,

I used v0.1.1 before and I didn't have any issue.. now that I'm using v0.1.3 I got this:

Sourcemap for "..node_modules/.vite/*.js" points to missing source files error.

Warning log:

Sourcemap for "...web/node_modules/.vite/@storybook_client-api.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/@storybook_client-logger.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/@storybook_react.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/react.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/@mdx-js_react.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/lodash_mapValues.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/ts-dedent.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/chunk-P3SATHUQ.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/chunk-OFZ2FDA6.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/@storybook_csf.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/global.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/fast-deep-equal.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/prop-types.js" points to missing source files
Sourcemap for "...node_modules/react-element-to-jsx-string/dist/esm/index.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/qs.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/polished.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/@emotion_styled.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/@emotion_core.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/@emotion_is-prop-valid.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/emotion-theming.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/doctrine.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/@base2_pretty-print-object.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/react_jsx-dev-runtime.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/react-is.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/uuid-browser_v4.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/react-textarea-autosize.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/markdown-to-jsx.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/memoizerific.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/deep-object-diff.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/html-tags.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/lodash_cloneDeep.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/lodash_isPlainObject.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/lodash_isFunction.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/chunk-HFSOX6BS.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/lodash_pickBy.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/lodash_isString.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/@storybook_addon-docs.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/acorn.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/lodash_uniq.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/escodegen.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/acorn-walk.js" points to missing source files
Sourcemap for "...web/node_modules/.vite/acorn-jsx.js" points to missing source files
[BABEL] Note: The code generator has deoptimised the styling of /...web/node_modules/.vite/chunk-5UCQLPD7.js?v=252f1ba1 as it exceeds the max of 500KB.

I have a branch working with previous version 0.1.1:

  "devDependencies": {
    "@babel/core": "^7.15.8",
    "@mdx-js/react": "^1.6.22",
    "@storybook/addon-actions": "^6.3.11",
    "@storybook/addon-docs": "^6.3.11",
    "@storybook/addon-essentials": "^6.3.11",
    "@storybook/addon-links": "^6.3.11",
    "@storybook/addons": "^6.3.11",
    "@storybook/react": "^6.3.11",
...
    "storybook-builder-vite": "^0.1.1",
    "typescript": "^4.4.3",
    "vite": "^2.5.1"
  },

And a non working branch with 0.1.3 and @storybook6.3.12

  "devDependencies": {
    "@babel/core": "^7.15.8",
    "@mdx-js/react": "^1.6.22",
    "@storybook/addon-actions": "^6.3.12",
    "@storybook/addon-docs": "^6.3.12",
    "@storybook/addon-essentials": "^6.3.12",
    "@storybook/addon-links": "^6.3.12",
    "@storybook/react": "^6.3.12",
    ...
    "storybook-builder-vite": "^0.1.3",
    "typescript": "^4.4.3",
    "vite": "^2.5.1"
  }

Any ideas what happened?

@eirslett
Copy link
Collaborator

Try using a newer version of Vite?

@IanVS
Copy link
Member

IanVS commented Oct 29, 2021

I find that this can also happen when you update packages but the cache still has old files. Try rm -rf node_modules/.vite and restart storybook.

@eddpascoal
Copy link
Author

eddpascoal commented Oct 31, 2021

Try using a newer version of Vite? (@eirslett )

I'm using the latest v2.6.13

I find that this can also happen when you update packages but the cache still has old files. Try rm -rf node_modules/.vite and restart storybook. (@IanVS )

I also get the log below when I do that:

12:11:20 PM [vite] Internal server error: Failed to resolve import "./chunk-PVZ2UEK3.js" from "node_modules/.vite/chunk-2GIWIXQG.js?v=3a7b4ca2". Does the file exist?
  Plugin: vite:import-analysis
  File: /home/.../app/web/node_modules/.vite/chunk-2GIWIXQG.js?v=3a7b4ca2
  1  |  import { require_is_regexp } from "./chunk-PVZ2UEK3.js";
     |                                     ^
  2  |  import { require_export, require_function_uncurry_this, require_global, require_is_pure, require_object_get_own_property_descriptor, require_require_object_coercible, require_to_length, require_to_string, require_well_known_symbol } from "./chunk-HNIKL5I4.js";
  3  |  import { __commonJS, __esm, init_define_import_meta_env, init_define_import_meta_env_NODE_PATH } from "./chunk-JST3G223.js"; // .../app/node_modules/core-js/internals/not-a-regexp.js
      at formatError (/home/.../app/node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:42189:46)
      at TransformContext.error (/home/.../app/node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:42185:19)
      at normalizeUrl (/home/.../app/node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:67281:26)
      at async TransformContext.transform (/home/.../app/node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:67421:57)
      at async Object.transform (/.../app/node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:42396:30)
      at async doTransform (/home/.../app/node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:56797:29)
12:11:20 PM [vite] Failed to load source map for /node_modules/.vite/chunk-HNIKL5I4.js?v=3a7b4ca2.
12:11:21 PM [vite] Failed to load source map for /node_modules/.vite/chunk-U6RFQSHA.js?v=3a7b4ca2.
12:11:21 PM [vite] Failed to load source map for /node_modules/.vite/uuid-browser_v4.js?v=bac73531.
12:11:21 PM [vite] Failed to load source map for /node_modules/.vite/global.js?v=bac73531.
12:11:21 PM [vite] Failed to load source map for /node_modules/.vite/@storybook_client-api.js?v=bac73531.
12:11:21 PM [vite] Failed to load source map for /node_modules/.vite/@storybook_client-logger.js?v=bac73531.
12:11:21 PM [vite] Failed to load source map for /node_modules/.vite/chunk-4M3HMNGZ.js?v=bac73531.
12:11:21 PM [vite] Failed to load source map for /node_modules/.vite/chunk-SM4OKSIY.js?v=bac73531.
12:11:21 PM [vite] Failed to load source map for /node_modules/.vite/chunk-GYOHUFFL.js?v=bac73531.
12:11:21 PM [vite] Failed to load source map for /node_modules/.vite/@storybook_addon-docs.js?v=bac73531.
...
Sourcemap for "/home/.../app/web/node_modules/.vite/acorn-walk.js" points to missing source files
Sourcemap for "/home/.../app/web/node_modules/.vite/acorn-jsx.js" points to missing source files
[BABEL] Note: The code generator has deoptimised the styling of /home/.../app/web/node_modules/.vite/chunk-XWLVHNRY.js?v=da61ba0e as it exceeds the max of 500KB.

The true is that even with this failing messages the storybook it will load ok and it seems to work fine. Don't understand what it means by points to missing source files if it works and the files are actually there. I can see thoses files on my folder... (e.g. "/home/.../app/web/node_modules/.vite/acorn-jsx.js")

I'm using monorepo approach and maybe it first tries to get from app/node_modules (core package) and raises this failing message and then tries to go to the expected package(web) and works. I wonder why was working fine with v.0.1.1.

@cymen
Copy link

cymen commented Nov 5, 2021

The root cause of this might be what is being discussed here: vitejs/vite#5563

@bnussman
Copy link

Also happening to me
Screen Shot 2021-11-15 at 11 15 20 AM

@eirslett
Copy link
Collaborator

Can you check if this still happens with the very latest version of Vite?

@eddpascoal
Copy link
Author

Hi @eirslett,

I'm using the latest versions:
vite@npm:2.6.14 [af97e] (via npm:^2.5.1 [af97e])
@storybook/react@npm:6.3.12 [af97e] (via npm:^6.3.12 [af97e])
storybook-builder-vite@npm:0.1.6 [af97e] (via npm:^0.1.3 [af97e])

I also noticed that if I run with the standard run (core with webpack configuration) and immediately after perform a vite builder run it works as it seems to take into consideration cached data provided by the first run. (Using cached manager)

Standard Run:

  1. Set configuration on .storybook/main.js for the storybook standard (webpack).
const path = require("path");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");

// Based on: https://storybook.js.org/docs/react/configure/webpack#extending-storybooks-webpack-config
module.exports = {

  stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
  addons: ["@storybook/addon-links", "@storybook/addon-essentials","storybook-addon-designs"],

  webpackFinal: async (config) => {
    // configuration to handle scss files when used within components consumed by a story
    config.module.rules.push({
      test: /\.scss$/,
      use: ["style-loader", "css-loader", "sass-loader"],
      include: path.resolve(__dirname, "../"),
    });
    config.resolve.plugins = [
      ...(config.resolve.plugins || []),
      new TsconfigPathsPlugin({
        extensions: config.resolve.extensions,
      }),
    ];
    // Return the altered config
    return config;
  }

};
  1. run start-storybook -h localhost -p 6006
  2. Result: All good. No warning/error was found.
info @storybook/react v6.3.12
info
info => Loading presets
info => Loading 1 config file in "/home/.../web/.storybook"
info => Loading 9 other files in "/home/.../web/.storybook"
info => Adding stories defined in "/home/.../web/.storybook/main.js"
info => Using implicit CSS loaders
info => Using default Webpack4 setup
(node:15854) DeprecationWarning: Default PostCSS plugins are deprecated. When switching to '@storybook/addon-postcss',
you will need to add your own plugins, such as 'postcss-flexbugs-fixes' and 'autoprefixer'.

See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-default-postcss-plugins for details.
(Use `node --trace-deprecation ...` to show where the warning was created)
10% building 1/1 modules 0 active
info => Using cached manager
webpack built preview c88a7cb9998e0cb2a68b in 22419ms
╭────────────────────────────────────────────────╮
│                                                │
│   Storybook 6.3.12 started                     │
│   23 s for preview                             │
│                                                │
│    Local:            http://localhost:6006/    │
│    On your network:  http://localhost:6006/    │
│                                                │
╰────────────────────────────────────────────────╯

Vite Builder run (right after standard run):

  1. I've refactor the main.js to have core builder with storybook-builder-vite as below.
module.exports = {

  stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
  addons: ["@storybook/addon-links", "@storybook/addon-essentials","storybook-addon-designs"],
  core: { builder: "storybook-builder-vite" }
};
  1. run start-storybook -h localhost -p 6006
  2. Result: All good. No warning/error was found and it is so much faster.
info @storybook/react v6.3.12
info
info => Loading presets
Pre-bundling dependencies:
  react
  react-dom
  @base2/pretty-print-object
  @emotion/core
  @emotion/is-prop-valid
  (...and 69 more)
(this will be run only when your dependencies or config have changed)

info => Using cached manager
╭────────────────────────────────────────────────╮
│                                                │
│   Storybook 6.3.12 started                     │
│   2.21 s for preview                           │
│                                                │
│    Local:            http://localhost:6006/    │
│    On your network:  http://localhost:6006/    │
│                                                │
╰────────────────────────────────────────────────╯

@IanVS
Copy link
Member

IanVS commented Nov 17, 2021

@eddpascoal I've got a PR up that I think should address this, but in the meantime, if you want, you can try removing any yarn.lock or package-lock.json and re-installing. Or, you might be able to force a resolution of @vitejs/plugin-react to 1.0.8. It's in range of what we have specified in this package, but your lockfile may have pinned it to an earlier version (dependency resolution can be complicated, hard to troubleshoot remotely).

@bnussman that looks like a different issue. You'll want to make sure that all your dependencies are pre-bundled by vite. You can add them to your optimizeDeps.include in viteFinal. You'll want something like:

config.optimizeDeps.include = [
    '@material-ui/styles',
    '@material-ui/core',
	.
    .
    .
    ...config.optimizeDeps.include
  ]

IanVS added a commit that referenced this issue Nov 17, 2021
Fixes #129 

Updating the version of `@vitejs/plugin-react` removes the warnings about missing source files.  See vitejs/vite#5438 (comment).

I also was seeing these warnings, and updating made them disappear.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants