Skip to content

Commit 61aa6eb

Browse files
build(config): update rollup config
1 parent 5052c2b commit 61aa6eb

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

config/grunt/sh.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = (grunt) => {
77
cmd: 'tsc --project src/tsconfig.json'
88
},
99
'build-es5': {
10-
cmd: 'rollup --config config/rollup/bundle.js'
10+
cmd: 'rollup --config config/rollup/bundle.mjs'
1111
},
1212
'clean': {
1313
cmd: 'rimraf build/*'

config/rollup/bundle.js renamed to config/rollup/bundle.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { readFile, readFileSync, readlink, stat } from 'fs';
22
import babel from '@rollup/plugin-babel';
3+
import { fileURLToPath } from 'url';
34
import { fs } from 'memfs';
45
import { join } from 'path';
56
import replace from '@rollup/plugin-replace';
67
import webpack from 'webpack';
7-
import webpackConfig from '../webpack/worker-es5';
8+
// eslint-disable-next-line node/file-extensions-in-import
9+
import webpackConfig from '../webpack/worker-es5.mjs';
810

911
const workerFile = readFileSync('src/worker/worker.ts', 'utf8');
1012
const result = /export\sconst\sworker\s=\s`(?<workerString>.*)`;/g.exec(workerFile);
@@ -21,7 +23,7 @@ export default new Promise((resolve, reject) => {
2123

2224
compiler.inputFileSystem = {
2325
readFile(path, ...args) {
24-
if (path === join(__dirname, '../../src/worker.js')) {
26+
if (path === fileURLToPath(new URL('../../src/worker.js', import.meta.url))) {
2527
args.pop()(null, "import 'async-array-buffer-worker';");
2628

2729
return;
@@ -30,14 +32,14 @@ export default new Promise((resolve, reject) => {
3032
return readFile(path, ...args);
3133
},
3234
readlink(path, callback) {
33-
if (path === join(__dirname, '../../src/worker.js')) {
34-
return readlink(__filename, callback);
35+
if (path === fileURLToPath(new URL('../../src/worker.js', import.meta.url))) {
36+
return readlink(fileURLToPath(new URL(import.meta.url)), callback);
3537
}
3638

3739
return readlink(path, callback);
3840
},
3941
stat(path, ...args) {
40-
if (path === join(__dirname, '../../src/worker.js')) {
42+
if (path === fileURLToPath(new URL('../../src/worker.js', import.meta.url))) {
4143
args.pop()(null, {
4244
isFile() {
4345
return true;
File renamed without changes.

0 commit comments

Comments
 (0)