fusion-cli
fusion-cli copied to clipboard
import syntax support in server-side src/node_modules
Type of issue
Bug
Current behavior
Places in src/node_modules/ components did not parse.
(function (exports, require, module, __filename, __dirname) { import React from 'react'
Expected behavior
Places in src/node_modules/ components will parse as well.
By react-scripts parsed well. Officialy. https://github.com/facebook/create-react-app/issues/1065
Your environment
-
fusion-cli version: 1.8.4
-
Node.js version (
node --version
): 9.11.1 -
npm version (
npm --version
): 6.3.0 -
Operating System: Ubuntu-18
Thanks for filing a bug report. We should be transpiling node_modules, so it's strange that you're seeing this. Here is our test case around node_module transpilation: https://github.com/fusionjs/fusion-cli/blob/83894b4ff4018b8daf04e90db90cf7d997b628d9/test/compiler/api.js#L336-L368
We might need to add some assertions, or get an example repo that demonstrates this issue in order to debug this.
@KevinGrandon thanks for answer. Not node_modules, but src/node_modules/ In react-scripts, if i wont include my custom packages globaly, i can put them into src/node_modules and import them by name. For example file src/node_modules/MyApp/index.js in src/main.js i can do just import MyApp from 'MyApp'; Not import MyApp from './node_modules/MyApp';
Now, when i do this, fusion-cli fined them (not say "can not find module MyApp"), but can not parse them with error "Unexpected token import". Just ignored **/node_modules.
Fusion.js currently transpiles and bundle node_modules
for the browser bundle, but unlike create-react-app
, Fusion.js also has a server app. Because of the possibility of binary Node.js modules in node_modules
, we do not include these in the server bundle.
That said, I think it might be reasonable to assume src/node_modules
, by virtue of being inside src/
, would not have any binary dependencies and thus could be transpiled/bundled into the server bundle.
To do this, I think we would simply need to adjust the appropriate globs accordingly.
@rtsao i have my own projects with react-scripts SSR (not so cool like fusion :) ), and src/node_modules/ correct resolves on server-side too.