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

Shims are not available in NPM package #791

Closed
thomas-jakemeyn opened this issue Nov 12, 2021 · 8 comments
Closed

Shims are not available in NPM package #791

thomas-jakemeyn opened this issue Nov 12, 2021 · 8 comments

Comments

@thomas-jakemeyn
Copy link

Context

I am trying to add FilerWebpackPlugin to an existing Webpack configuration.

Problem

All imports of fs are properly replaced by node_modules/filer/shims/fs.js. However, that file cannot be found.

Analysis

The shims are not made available in the NPM package.

@humphd
Copy link
Contributor

humphd commented Nov 13, 2021

I've shipped v1.3.1 to npm, do you want to try that? https://github.com/filerjs/filer/releases/tag/v1.3.1

@thomas-jakemeyn
Copy link
Author

Hello @humphd,

As far as I can see, the shims are still missing in the NPM library v1.3.1.
Also, I quickly checked the history and I could not find any commit that would have fixed this problem.

@humphd
Copy link
Contributor

humphd commented Nov 15, 2021

cc @bcheidemann

@bcheidemann
Copy link
Contributor

@humphd the "shims" directory in the root of the project needs to be released to NPM. Could you advise on what changes need to be made to facilitate this? Happy to put up a PR.

@bcheidemann
Copy link
Contributor

@thomas-jakemeyn this is the workaround until the files are released to NPM:

  1. Copy the 'shims' directory from this repo into your project. This can be wherever you want but for arguments sake lets say you copy the contents to src/filer/shims.
  2. You then need to update the following imports:
// src/filer/shims/fs.js
// replace
const { FileSystem } = require('../src/index');
// with
const { FileSystem } = require('filer');

// src/filer/shims/path.js
// replace
const { path } = require('../src/index');
// with
const { path } = require('filer');

// src/filer/shims/providers/default.js
// replace
const { Default } = require('../../src/providers/index');
// with
const { Default } = require('filer/src/providers/index');

// src/filer/shims/providers/indexeddb.js
// replace
const IndexedDB = require('../../src/providers/indexeddb');
// with
const IndexedDB = require('filer/src/providers/indexeddb');

// src/filer/shims/providers/memory.js
// replace
const Memory = require('../../src/providers/memory');
// with
const Memory = require('filer/src/providers/memory');
  1. Instantiate the FilerWebpackPlugin class with the following options
// webpack.config.js
module.exports = {
  plugins: [
    new filer.FilerWebpackPlugin({
      shimsDir: '<rootDir>/src/filer/shims`,
    }),
  ],
}

This should work but I haven't tested it and I appreciate it's a lot of effort to go to. Hopefully it will be possible to release a new version of filer which includes the shims and webpack folders soon.

@humphd
Copy link
Contributor

humphd commented Nov 15, 2021

@bcheidemann ah, I see. We need to update https://github.com/filerjs/filer/blob/master/package.json#L77-L81 and potentially the build script to copy things where they are expected when you npm install filer. If you want to do that, that would be great.

@humphd
Copy link
Contributor

humphd commented Nov 15, 2021

Should be fixed by v1.4.1

@humphd humphd closed this as completed Nov 15, 2021
@bcheidemann
Copy link
Contributor

Confirmed, shims are now present :)

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