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

babelInclude on a symlink folder does not work #107

Closed
royair opened this issue Jun 30, 2019 · 5 comments
Closed

babelInclude on a symlink folder does not work #107

royair opened this issue Jun 30, 2019 · 5 comments

Comments

@royair
Copy link

royair commented Jun 30, 2019

i have an external component folder linked to my web project through npm-link.
on my web project i have configured config-override to babel parse the npm-linked folder withe the proper plugin.

this works well when not using npm link and simply downloading from npm
when using npm-link i get errors related to not using "babel/plugin-proposal-class-properties"

tried also replacing:

path.resolve('node_modules/@blio'),

with

fs.realpathSync('node_modules/@blio')

and it didn't help either

i am using:
"react-scripts": "3.0.0",
"customize-cra": "^0.2.14",

const { override, fixBabelImports, addBabelPlugin, babelInclude, addLessLoader } = require('customize-cra');
const path                                                                       = require('path');

module.exports = override(
  fixBabelImports('import', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: true,
  }),
  addLessLoader({
    javascriptEnabled: true,
    modifyVars: { '@primary-color': '#047fff' },
  }),
  addBabelPlugin('@babel/plugin-proposal-class-properties'),
  babelInclude([
    path.resolve('src'), // don't forget this
    path.resolve('node_modules/@blio'),
  ]),
);
@royair royair changed the title bable loder to an npm link folder does not seem to work babelInclude on a symlink folder does not work Jun 30, 2019
@with-heart
Copy link
Collaborator

Since babelInclude simply injects the provided array into babel-loader configuration, any issues with how babel-loader uses that configuration are outside the scope of the customize-cra project. Since this works fine when not using link, it means the issue stems from babel-loader and not customize-cra.

It appears that symlinks with babel-loader are a common issue that people face. I was able to find an issue that may be relevant to your issue: babel/babel-loader#149

Unfortunately I don't know enough about babel-loader to assist beyond pointing you in that direction. Hope that helps!

@royair
Copy link
Author

royair commented Jul 2, 2019

Thanks Mark,
I've found a workaround: using fs.realPathSync instead of Path.resolve

@with-heart
Copy link
Collaborator

Perfect! That's good to know. Thanks @royair

@switz
Copy link

switz commented Aug 7, 2019

Thanks Mark,
I've found a workaround: using fs.realPathSync instead of Path.resolve

Life saver! Only one note for future visitors, it's fs.realpathSync (see casing).

Thanks so much @royair

@royair
Copy link
Author

royair commented Aug 7, 2019

fs.realpathSync indeed!
Thanks

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

No branches or pull requests

3 participants