Open renshawdev opened 4 years ago
@paulrenshaw , when you run bit add
with /*
, it tries to create a component from each one of the files in that directory. In your case, when you have two files, only one of them is the main file, so it fails on the readme saying the main-file is missing.
Just change your bit add
command to the following:
bit add src/components/HelloWorld --main src/components/HelloWorld/HelloWorld.vue -t tests/unit/{PARENT}/*.spec.ts
.
@paulrenshaw , when you run
bit add
with/*
, it tries to create a component from each one of the files in that directory. In your case, when you have two files, only one of them is the main file, so it fails on the readme saying the main-file is missing.Just change your
bit add
command to the following:bit add src/components/HelloWorld --main src/components/HelloWorld/HelloWorld.vue -t tests/unit/{PARENT}/*.spec.ts
.
@davidfirst Same result
Oh I see, so that's an issue with bit test
not with bit add
.
Any chance that the README file was added for some reason as a test file?
you can verify it by running bit show <id>
or by looking into .bitmap file.
It's not added as a test file. I think it's an issue with the webpack config in the vue compiler. I think it needs to use ignore-loader set to match .md files. I'll have a go at creating my own modified version.
It worked! I followed the instructions here https://discourse.bit.dev/t/can-i-modify-a-build-test-environments/28 as it says to in the readme for the vue compiler here https://github.com/teambit/envs/blob/master/packages/vue/readme.md
i.e. I initialised a new bit workspace in a new directory, installed the bit.envs/bundlers/vue component (without the --compiler flag), installed the ignore-loader npm package (in the vue component folder: components/bundlers/vue/vue) and added to the webpack config to match .md files:
"rules": [
{
"loader": "ignore-loader",
"test": /\.md&/
}
...
tagged it, exported to my own collection, went back to my original vue project and installed the component from my collection as the compiler, ran 'bit tag' and the build stage passed etc.
output:
$ bit import paulrenshaw.vue/bundlers/vue --compiler
the following component environments were installed
- paulrenshaw.vue/bundlers/vue@2.6.21
$ bit add src/components/HelloWorld/README.md --id hello-world
tracking component hello-world@0.0.1:
added src/components/HelloWorld/HelloWorld.vue
added src/components/HelloWorld/README.md
added tests/unit/HelloWorld/HelloWorld.spec.ts
$ bit tag hello-world
√ building component - hello-world@0.0.1
1 component(s) tagged
(use "bit export [collection]" to push these components to a remote")
(use "bit untag" to unstage versions)
changed components
(components that got a version bump)
> hello-world@0.0.2
It worked!
P.S. I think this should be added to the bit.envs/bundlers/vue component on bit so that others don't have to figure this out in future. Unless some people do want webpack to try to parse .md files in vue component folders.
@paulrenshaw , thanks for the update! I re-opened it for now, to make sure we handle it. I'm going to move it to the bit.envs repo. @JoshK2 , can you take a look, it looks like a bug in the Vue compiler.
Describe the bug
Trying to include a README.md in the component folder as per the instructions shown in an empty collection, but fails due to an error related to the README file. Everything works as expected without one.
Steps to Reproduce
Readme.md
bit add src/components/HelloWorld/* --main src/components/HelloWorld/HelloWorld.vue -t tests/unit/{PARENT}/*.spec.ts
(same as used without README.md)Alternatively:
bit build
orbit test
orbit tag
Expected Behavior
Component tests and build complete without errors when following instructions. NB same thing happens with index.js file in component folder and not specifying --main in add command
Screenshots, exceptions and logs
Specifications
Additional context
Without README![image](https://user-images.githubusercontent.com/54814730/74387533-b1480b80-4df0-11ea-9f74-8ebb3003c43f.png)
bit tag after adding to already tracked component (stalls on building component)![image](https://user-images.githubusercontent.com/54814730/74387199-d4be8680-4def-11ea-9d35-e6197d035460.png)
bit test after adding to already tracked component![image](https://user-images.githubusercontent.com/54814730/74387142-a93b9c00-4def-11ea-80b5-312883b0c5c4.png)