| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a4db4c2 commit 74c41c5
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1 +1 @@ | |||
| 1 | - console.log('foo'); | ||
| 1 | + export default 'foo'; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,5 @@ | |||
| 1 | 1 | import foo from './foo'; | |
| 2 | 2 | ||
| 3 | + __export__ = foo; | ||
| 4 | + | ||
| 3 | 5 | export default foo; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,22 @@ | |||
| 1 | + import Module from 'module'; | ||
| 2 | + import path from 'path'; | ||
| 3 | + | ||
| 4 | + const parentModule = module; | ||
| 5 | + | ||
| 6 | + export default (code) => { | ||
| 7 | + const resource = 'test.js'; | ||
| 8 | + const module = new Module(resource, parentModule); | ||
| 9 | + // eslint-disable-next-line no-underscore-dangle | ||
| 10 | + module.paths = Module._nodeModulePaths( | ||
| 11 | + path.resolve(__dirname, '../fixtures') | ||
| 12 | + ); | ||
| 13 | + module.filename = resource; | ||
| 14 | + | ||
| 15 | + // eslint-disable-next-line no-underscore-dangle | ||
| 16 | + module._compile( | ||
| 17 | + `let __export__;${code};module.exports = __export__;`, | ||
| 18 | + resource | ||
| 19 | + ); | ||
| 20 | + | ||
| 21 | + return module.exports; | ||
| 22 | + }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | import path from 'path'; | |
| 2 | 2 | ||
| 3 | 3 | import webpack from 'webpack'; | |
| 4 | - import memfs from 'memfs'; | ||
| 4 | + import { createFsFromVolume, Volume } from 'memfs'; | ||
| 5 | 5 | ||
| 6 | 6 | export default (fixture, loaderOptions = {}, config = {}) => { | |
| 7 | 7 | const fullConfig = { | |
@@ -34,9 +34,7 @@ export default (fixture, loaderOptions = {}, config = {}) => { | |||
| 34 | 34 | const compiler = webpack(fullConfig); | |
| 35 | 35 | ||
| 36 | 36 | if (!config.outputFileSystem) { | |
| 37 | - const outputFileSystem = memfs; | ||
| 38 | - | ||
| 39 | - outputFileSystem.vol.reset(); | ||
| 37 | + const outputFileSystem = createFsFromVolume(new Volume()); | ||
| 40 | 38 | // Todo remove when we drop webpack@4 support | |
| 41 | 39 | outputFileSystem.join = path.join.bind(path); | |
| 42 | 40 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,13 +1,19 @@ | |||
| 1 | - import { getCompiler, compile, normalizeErrors, readAsset } from './helpers'; | ||
| 1 | + import { | ||
| 2 | + compile, | ||
| 3 | + execute, | ||
| 4 | + getCompiler, | ||
| 5 | + normalizeErrors, | ||
| 6 | + readAsset, | ||
| 7 | + } from './helpers'; | ||
| 2 | 8 | ||
| 3 | 9 | describe('loader', () => { | |
| 4 | 10 | it('should work', async () => { | |
| 5 | 11 | const compiler = getCompiler('simple.js'); | |
| 6 | 12 | const stats = await compile(compiler); | |
| 7 | 13 | ||
| 8 | - expect(readAsset('main.bundle.js', compiler, stats)).toMatchSnapshot( | ||
| 9 | - 'result' | ||
| 10 | - ); | ||
| 14 | + expect( | ||
| 15 | + execute(readAsset('main.bundle.js', compiler, stats)) | ||
| 16 | + ).toMatchSnapshot('result'); | ||
| 11 | 17 | expect(normalizeErrors(stats.compilation.warnings)).toMatchSnapshot( | |
| 12 | 18 | 'warnings' | |
| 13 | 19 | ); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments